:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #e3e6ea;
  --text: #1c2430;
  --muted: #7a8494;
  --accent: #2563eb;
  --accent-soft: #e8efff;
  --danger: #dc2626;
  --hl: #fff2a8;
  --radius: 8px;
  --shadow: 0 4px 24px rgba(15, 23, 42, .12);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151a;
    --panel: #1a1e25;
    --border: #2a303a;
    --text: #e4e8ee;
    --muted: #8892a2;
    --accent: #5b8cff;
    --accent-soft: #1f2a44;
    --hl: #5a4b00;
    --shadow: 0 4px 24px rgba(0, 0, 0, .5);
  }
}
* { box-sizing: border-box; }
/* Höhe der eigenen Titelleiste (nur Desktop-Client) */
:root { --tb: 0px; }
html.desktop { --tb: 52px; }
html, body { margin: 0; height: 100%; }
html.desktop body { padding-top: var(--tb); }
body { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px 12px; cursor: pointer; white-space: nowrap;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.danger { color: var(--danger); }
button.danger:hover { border-color: var(--danger); }
button.icon { border: none; background: none; padding: 4px; border-radius: 6px; color: var(--muted); }
button.icon:hover { background: var(--bg); }
button.icon:hover { color: var(--accent); }
button.link { border: none; background: none; color: var(--accent); padding: 4px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.center { display: flex; align-items: center; justify-content: center; height: 100%; padding: 20px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.login { display: flex; flex-direction: column; gap: 12px; padding: 32px; width: 340px; }
.login h1 { margin: 0 0 8px; }

/* Layout */
.layout { display: grid; grid-template-columns: 260px 1fr; height: calc(100vh - var(--tb)); }
.layout.with-detail { grid-template-columns: 260px 1fr minmax(380px, 42%); }
.sidebar {
  background: var(--panel); border-right: 1px solid var(--border); overflow-y: auto;
  display: flex; flex-direction: column; padding: 10px 8px;
}
.sidebar-backdrop { display: none; }
@media (max-width: 900px) { .sidebar-backdrop { display: block; } }
.brand-actions { display: inline-flex; align-items: center; gap: 2px; }
.brand { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 17px; padding: 4px 8px 12px; }
.nav-item {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 6px; cursor: pointer;
  justify-content: space-between; user-select: none;
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item.small { padding: 4px 8px; }
.nav-item.drop-target { outline: 2px dashed var(--accent); background: var(--accent-soft); }
.count { color: var(--muted); font-size: 12px; font-weight: 400; }
.section-head {
  display: flex; justify-content: space-between; align-items: center; margin: 16px 8px 4px;
  text-transform: uppercase; font-size: 11px; letter-spacing: .05em; color: var(--muted); font-weight: 600;
}
.tree-row { justify-content: flex-start; }
.tree-row .row-actions { display: none; }
.tree-row:hover .row-actions { display: inline-flex; }
.tree-row:hover .count { display: none; }
.coll-icon { display: inline-flex; flex-shrink: 0; color: var(--muted); }
.tree-row.active .coll-icon { color: inherit; }
.tree-search { position: relative; display: flex; align-items: center; margin: 0 8px 6px; }
.tree-search > .ico { position: absolute; left: 8px; color: var(--muted); pointer-events: none; }
.tree-search input { width: 100%; padding: 5px 28px; font-size: 13px; border-radius: 8px; }
.tree-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.tree-search button { position: absolute; right: 2px; padding: 3px; color: var(--muted); }
.twisty { width: 16px; flex-shrink: 0; display: inline-flex; color: var(--muted); }
.ai-lock { display: inline-flex; color: var(--muted); margin-right: 4px; }
.token-list { list-style: none; padding: 0; margin: 8px 0; }
.token-list li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.modal .token-list label.token-perm { flex-direction: row; align-items: center; gap: 4px; cursor: pointer; }
.token-list li.token-row { flex-wrap: wrap; }
.token-list button.token-scope { display: inline-flex; align-items: center; gap: 4px; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.token-scope-edit { flex-basis: 100%; background: var(--bg-alt, rgba(127,127,127,.08)); border-radius: 6px; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.token-scope-tree { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow: auto; margin-left: 22px; }
.token-scope-actions { display: flex; gap: 8px; margin-top: 6px; }
.token-new { background: var(--bg-alt, rgba(127,127,127,.08)); border-radius: 6px; padding: 8px 10px; margin: 8px 0; }
.token-new code { display: block; white-space: pre-wrap; word-break: break-all; user-select: all; margin: 4px 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 8px; }
.sidebar-foot { margin-top: auto; padding: 16px 8px 4px; }

.main { display: flex; flex-direction: column; min-width: 0; height: calc(100vh - var(--tb)); }
.toolbar { display: flex; gap: 8px; padding: 12px 16px; align-items: center; border-bottom: 1px solid var(--border); background: var(--panel); }
.search { flex: 1; position: relative; display: flex; align-items: center; }
.search input { width: 100%; padding: 10px 36px; font-size: 15px; border-radius: 10px; }
.search-icon { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.spinner {
  position: absolute; right: 12px; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent); animation: spin .7s linear infinite;
}
.spinner.shifted { right: 44px; }
.search-clear { position: absolute; right: 6px; padding: 4px; color: var(--muted); }
.search-clear:hover { color: var(--text); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.filterbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 16px; align-items: center; min-height: 36px; }
.bulkbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 16px;
  background: var(--accent-soft); border-bottom: 1px solid var(--border);
}

/* Chips */
.chip {
  --tag: var(--accent);
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--border); background: var(--panel); cursor: pointer; white-space: nowrap; max-width: 260px;
  overflow: hidden; text-overflow: ellipsis;
}
.chip.tag { border-color: color-mix(in srgb, var(--tag) 45%, transparent); color: var(--tag); }
.chip.tag.active { background: var(--tag); color: #fff; }
.chip.tag.active .count { color: #fff; }
.chip.coll { background: var(--bg); }
.chip.removable:hover { border-color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }

/* Ergebnisse */
.results { overflow-y: auto; flex: 1; padding: 0 16px 24px; }
.result-head { padding: 0 10px 4px; }
.row {
  display: grid; grid-template-columns: 20px 56px 1fr; gap: 12px; padding: 10px; border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer; align-items: start;
}
.row:hover { background: var(--panel); border-color: var(--border); }
.row.selected { background: var(--accent-soft); border-color: var(--accent); }
.row.checked { background: var(--accent-soft); }
.row input[type=checkbox] { margin-top: 4px; }
.thumb {
  width: 56px; height: 72px; border-radius: 4px; overflow: hidden; background: var(--bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.ico.kind-icon { width: 30px; height: 30px; }
.ico.kind-icon svg { stroke-width: 1.6; }
.row-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.row-title { display: flex; gap: 8px; align-items: center; }
.title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snippet { color: var(--muted); font-size: 13px; line-height: 1.45; white-space: pre-line; max-height: 4.4em; overflow: hidden; }
.snippet b { background: var(--hl); color: var(--text); font-weight: 600; border-radius: 2px; padding: 0 1px; }
.meta { display: flex; gap: 12px; color: var(--muted); font-size: 12px; }
.meta .filename { max-width: 280px; }
.meta .sender { display: inline-flex; align-items: center; gap: 4px; min-width: 0; max-width: 220px; color: var(--text); }
.meta .sender .ico { flex: none; }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.bad { background: #fde2e2; color: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 80px 20px; }
.more { display: block; margin: 16px auto; }

/* Detail */
.detail {
  border-left: 1px solid var(--border); background: var(--panel); overflow-y: auto; height: calc(100vh - var(--tb));
  display: flex; flex-direction: column; gap: 10px; padding: 12px 16px 32px;
}
.detail-head { display: flex; gap: 8px; align-items: center; }
.title-input { flex: 1; font-size: 17px; font-weight: 600; border-color: transparent; }
.title-input:hover { border-color: var(--border); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.notice { background: var(--accent-soft); padding: 8px 12px; border-radius: var(--radius); }
.notice.bad { background: #fde2e2; color: var(--danger); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.preview-wrap { height: 55vh; min-height: 300px; flex-shrink: 0; }
.preview { width: 100%; height: 100%; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.preview.img { display: flex; align-items: center; justify-content: center; overflow: auto; background: var(--bg); }
.preview.img img { max-width: 100%; max-height: 100%; }
.preview.none { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: var(--bg); color: var(--muted); }
.fulltext {
  height: 100%; overflow: auto; margin: 0; padding: 12px; background: var(--bg); border-radius: var(--radius);
  white-space: pre-wrap; font-size: 12.5px; line-height: 1.5;
}
.fields { display: flex; flex-direction: column; gap: 10px; }
.fields label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
.fields label input, .fields label textarea { color: var(--text); font-size: 14px; }
.field-label { color: var(--muted); font-size: 12px; margin-top: 4px; }
.picker summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.picker input[type=search] { width: 100%; margin: 6px 0; }
.check input[type=checkbox] { width: auto; flex: none; margin: 0; }
.check { justify-content: flex-start; text-align: left; }
.picker-list { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.check { display: flex; gap: 6px; align-items: center; cursor: pointer; padding: 2px 0; color: var(--text) !important; font-size: 13px !important; flex-direction: row !important; }
.tag-input { width: 110px; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.info { font-size: 13px; border-collapse: collapse; table-layout: fixed; width: 100%; }
.info td { padding: 2px 0; }
.info td:first-child { color: var(--muted); width: 110px; }
.versions { margin: 0; padding-left: 18px; font-size: 13px; }

/* Upload */
.uploads { position: fixed; right: 16px; bottom: 16px; width: 340px; max-height: 50vh; overflow: auto; padding: 10px 12px; z-index: 20; }
.uploads-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.uploads ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.uploads li { display: flex; gap: 8px; font-size: 13px; cursor: pointer; }
.up-done .small { color: #16a34a; }
.up-error .small { color: var(--danger); }
.up-duplicate .small { color: #d97706; }
.drop-overlay {
  position: fixed; inset: var(--tb) 0 0 0; background: color-mix(in srgb, var(--accent) 18%, transparent); z-index: 50;
  display: flex; align-items: center; justify-content: center; pointer-events: none;
  border: 3px dashed var(--accent); font-size: 24px; font-weight: 600; color: var(--accent); text-align: center;
}
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1f2937; color: #fff;
  padding: 10px 18px; border-radius: var(--radius); box-shadow: var(--shadow); z-index: 100; cursor: pointer; max-width: 80vw;
}
.toast.error { background: var(--danger); }
.modal-bg { position: fixed; inset: var(--tb) 0 0 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 60; }
.modal { padding: 20px 24px; width: min(520px, 92vw); max-height: 90vh; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.modal h2, .modal h3 { margin: 4px 0; }
.modal label { display: flex; flex-direction: column; gap: 4px; }
.modal hr { border: none; border-top: 1px solid var(--border); width: 100%; }
/* Einstellungen: links die Bereiche, rechts der gewählte */
.modal.settings { width: min(820px, 94vw); height: min(640px, 90vh); padding: 0; gap: 0; overflow: hidden; }
.settings-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 12px 20px; border-bottom: 1px solid var(--border); }
.settings-body { display: flex; flex: 1; min-height: 0; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; padding: 10px 8px; width: 190px; flex-shrink: 0; border-right: 1px solid var(--border); overflow-y: auto; }
.settings-nav button { justify-content: flex-start; border-color: transparent; background: none; padding: 7px 10px; }
.settings-nav button:hover { background: var(--bg); border-color: transparent; }
.settings-nav button.active { background: var(--accent-soft); color: var(--accent); }
.settings-pane { flex: 1; min-width: 0; overflow-y: auto; padding: 16px 24px 20px; display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 640px) {
  .modal.settings { height: 90vh; }
  .settings-body { flex-direction: column; }
  .settings-nav { flex-direction: row; width: auto; border-right: none; border-bottom: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; padding: 6px 8px; }
  .settings-pane { padding: 14px 16px; }
}
.tips { padding-left: 18px; line-height: 1.7; }
.tips code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.row-buttons { display: flex; justify-content: space-between; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; }
.error-text { color: var(--danger); }

/* Schmale Fenster */
@media (max-width: 900px) {
  .layout, .layout.with-detail { grid-template-columns: 1fr; }
  /* Seitenleiste als ausklappbares Menü */
  .sidebar {
    position: fixed; top: var(--tb); bottom: 0; left: 0; width: min(300px, 86vw); z-index: 40;
    transform: translateX(-100%); transition: transform .2s ease; visibility: hidden;
    box-shadow: var(--shadow); padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
  .sidebar.open { transform: none; visibility: visible; }
  .sidebar-backdrop { position: fixed; inset: var(--tb) 0 0 0; background: rgba(0,0,0,.35); z-index: 39; }
  .sidebar .nav-item { padding: 9px 8px; }
  .sidebar .nav-item.small { padding: 7px 8px; }
  /* Ohne Maus: Aktionen der gewählten Sammlung immer zeigen */
  .tree-row.active .row-actions { display: inline-flex; }
  .tree-row.active .count { display: none; }
  .detail { position: fixed; inset: var(--tb) 0 0 0; z-index: 30; }
  .titlebar .tb-brand { width: auto; }
  .toolbar .sort, .tb-main .sort { display: none; }
}

/* Icons */
.ico { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; flex-shrink: 0; line-height: 0; }
.ico svg { width: 100%; height: 100%; }
.ico.sm { width: 13px; height: 13px; }
.ico.ok { color: #16a34a; }
.label { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.nav-item .label .ico:not(.kind) { color: var(--muted); }
.nav-item.active .label .ico:not(.kind) { color: var(--accent); }
.brand-name { display: inline-flex; align-items: center; gap: 8px; }
.brand-version { font-size: 11px; font-weight: 400; opacity: .55; align-self: flex-end; margin-bottom: 2px; }
.ico.brand-logo { width: 22px; height: 22px; color: var(--accent); }
img.brand-logo { width: auto; max-width: 96px; height: 22px; object-fit: contain; }
h1 img.brand-logo { height: 28px; max-width: 140px; }
.branding-preview { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.branding-preview img { max-height: 48px; max-width: 160px; object-fit: contain; }
h1 .ico.brand-logo { width: 28px; height: 28px; }
.chip .ico.sm:last-child { opacity: .55; }
.chip.removable:hover .ico.sm:last-child { opacity: 1; color: var(--danger); }
.kind { color: var(--muted); }
.kind-pdf { color: #dc2626; }
.kind-word { color: #2563eb; }
.kind-spreadsheet { color: #16a34a; }
.kind-presentation { color: #ea580c; }
.kind-image { color: #9333ea; }
.kind-email { color: #0891b2; }
.kind-text { color: #64748b; }
.kind-markdown { color: #0f766e; }

/* Freigaben */
.share-dialog { width: min(620px, 94vw); }
.share-form { display: flex; flex-direction: column; gap: 10px; }
.share-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.share-grid label { font-size: 12px; color: var(--muted); }
.share-grid input, .share-grid select { color: var(--text); font-size: 14px; }
.share-form .check { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.share-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.share-item { display: flex; flex-direction: column; gap: 4px; }
.share-item.expired { opacity: .55; }
.share-link { display: flex; align-items: center; gap: 4px; }
.share-link input { flex: 1; min-width: 0; font-family: ui-monospace, monospace; font-size: 12px; }
button.icon.danger:hover { color: var(--danger); }
@media (max-width: 560px) { .share-grid { grid-template-columns: 1fr; } }

/* Öffentliche Freigabeseite */
.public { height: 100%; overflow: auto; display: flex; flex-direction: column; }
.public-head { display: flex; align-items: center; gap: 12px; padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--border); font-weight: 600; }
.public > .notice { margin: 12px auto 0; width: min(900px, 94vw); cursor: pointer; }
.public-main { width: min(900px, 94vw); margin: 0 auto; padding: 20px 0 40px; display: flex; flex-direction: column; gap: 14px; }
.public-title { display: flex; flex-direction: column; gap: 4px; }
.public-title h1 { margin: 0; font-size: 22px; display: flex; align-items: center; gap: 10px; }
.public-title h1 .ico { width: 22px; height: 22px; color: var(--muted); }
.public-msg { padding: 24px 32px; max-width: 420px; text-align: center; }
.public-upload { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 16px; }
.public-upload > span:first-child { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.public-preview { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.public-preview.img { display: flex; justify-content: center; background: var(--panel); padding: 8px; height: auto; max-height: 75vh; overflow: auto; }
.public-preview.img img { max-width: 100%; }
.public-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.public-item { display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: center; padding: 10px 14px; }
.public-item .thumb { width: 56px; height: 72px; }
.public-actions { display: flex; gap: 6px; }
a.button {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: inherit;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 12px; white-space: nowrap;
}
a.button:hover { border-color: var(--accent); }
@media (max-width: 640px) {
  .public-item { grid-template-columns: 44px 1fr; }
  .public-actions { grid-column: 1 / -1; }
}

/* Euro-Office */
.office-overlay { position: fixed; inset: var(--tb) 0 0 0; z-index: 80; background: var(--panel); display: flex; flex-direction: column; }
.office-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.office-overlay > .notice { margin: 8px 12px 0; }

/* Noten-Ansicht (crates/web/notenleser/, bringt eigene Stile mit) – deckt auch die Titelleiste des Desktop-Clients ab */
/* (doppelte Klasse: .nl-root aus notenleser.css setzt sonst position: relative) */
.notenleser-layer, .notenleser-layer.nl-root { position: fixed; inset: 0; width: auto; height: auto; z-index: 90; background: #000; }
.filterbar button.small { padding: 2px 10px; display: inline-flex; align-items: center; gap: 4px; }
.office-frame-wrap { flex: 1; min-height: 0; }
.office-frame-wrap > *, .office-frame-wrap iframe { width: 100%; height: 100%; border: 0; display: block; }

/* Download des Desktop-Clients */
.login-page { flex-direction: column; gap: 16px; }
.login-download { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.login-download:hover { color: var(--accent); }
.downloads { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.downloads li { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); }
.downloads li.recommended { border-color: var(--accent); background: var(--accent-soft); }
.downloads a { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-weight: 500; }

/* Übersicht (Dashboard) */
:root { --series-1: #2a78d6; --series-2: #eb6834; --series-other: #c9ccd1; --track: #eef0f2; --warning: #b45309; }
@media (prefers-color-scheme: dark) {
  :root { --series-1: #3987e5; --series-2: #d95926; --series-other: #4a505a; --track: #232831; --warning: #f59e0b; }
}
.dashboard { overflow-y: auto; padding: 20px 24px 32px; display: flex; flex-direction: column; gap: 16px; }
.dashboard-head { display: flex; align-items: center; justify-content: space-between; }
.dashboard-head h2 { margin: 0; }
.dash-card { padding: 16px 18px; min-width: 0; }
.dash-card h3 { margin: 0 0 8px; font-size: 15px; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 16px; }
.hero-figure { font-size: 48px; font-weight: 600; line-height: 1.1; margin: 4px 0; }
.hero-unit { font-size: 18px; font-weight: 500; color: var(--muted); }
.status-warning { display: flex; align-items: center; gap: 6px; color: var(--warning); font-weight: 500; margin: 8px 0; }
.seg-bar { display: flex; gap: 2px; height: 28px; margin: 14px 0 10px; }
.seg { min-width: 2px; border-radius: 4px; color: #fff; font-size: 12px; font-weight: 600; line-height: 28px; padding-left: 8px; overflow: hidden; white-space: nowrap; }
.seg-docs { background: var(--series-1); }
.seg-extra { background: var(--series-2); }
.seg-other { background: var(--series-other); color: var(--text); }
.seg-free { background: var(--track); color: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }
.legend { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend li .muted { white-space: nowrap; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.storage-details { margin-top: 12px; font-size: 13px; }
.storage-details summary { cursor: pointer; color: var(--muted); }
.num-table { border-collapse: collapse; margin: 8px 0; width: 100%; max-width: 440px; }
.num-table td { padding: 3px 12px 3px 0; border-bottom: 1px solid var(--border); }
.num-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.num-table .sum td { font-weight: 600; border-bottom: none; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: 12px; }
.stat-tile { padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.stat-tile.clickable { cursor: pointer; }
.stat-tile.clickable:hover { border-color: var(--accent); }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 24px; font-weight: 600; }
.hbars { display: grid; grid-template-columns: minmax(0, max-content) minmax(40px, 1fr) auto; row-gap: 4px; }
.hbar-row { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; align-items: center; gap: 10px; padding: 4px 0; border-radius: 6px; cursor: pointer; font-size: 13px; }
.hbar-row:hover { background: var(--bg); }
.hbar-label { display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; padding-left: 6px; }
.hbar-track { height: 10px; }
.hbar { display: block; height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.hbar-value { font-variant-numeric: tabular-nums; white-space: nowrap; padding-right: 6px; }
.vbars { display: flex; align-items: stretch; gap: 2px; height: 160px; margin-top: 8px; }
.vbar-col { flex: 1; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.vbar-col:hover .vbar { filter: brightness(1.15); }
.vbar-col:hover .vbar-label { color: var(--text); }
.vbar-value { font-size: 12px; height: 16px; color: var(--text); }
.vbar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; border-bottom: 1px solid var(--border); }
.vbar { display: block; width: min(70%, 24px); background: var(--series-1); border-radius: 4px 4px 0 0; }
.vbar.zero { height: 0 !important; }
.vbar-label { font-size: 11px; color: var(--muted); margin-top: 4px; }
.dash-docs { list-style: none; padding: 0; margin: 0; }
.dash-docs li { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 6px; border-radius: 6px; cursor: pointer; }
.dash-docs li:hover { background: var(--bg); }
.dash-doc-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Update-Hinweis (Desktop-Client) */
.update-banner {
  position: fixed; right: 20px; bottom: 20px; z-index: 90; width: min(420px, calc(100vw - 40px));
  padding: 14px 16px; display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; align-items: start;
}
.update-banner > .ico { color: var(--accent); width: 20px; height: 20px; margin-top: 2px; }
.update-text { display: flex; flex-direction: column; gap: 2px; }
.update-banner .button-row { grid-column: 2; }

/* Smartphone */
.mobile-only { display: none !important; }
@media (max-width: 900px) {
  .mobile-only { display: inline-flex !important; }
  .main, .detail { height: calc(100dvh - var(--tb)); }
  .dashboard-head h2 { flex: 1; }
  .dashboard-head { gap: 8px; }
}
@media (max-width: 600px) {
  .toolbar { padding: 8px 10px; gap: 6px; }
  .toolbar .btn-text, .dashboard-head .btn-text { display: none; }
  .toolbar button.primary, .dashboard-head button:not(.icon) { padding: 8px 10px; }
  .search input { font-size: 16px; } /* verhindert Auto-Zoom unter iOS */
  .dashboard { padding: 12px 10px 24px; gap: 12px; }
  .dashboard-head h2 { font-size: 20px; }
  .dash-card { padding: 12px 14px; }
  .dash-grid { gap: 12px; }
  .hero-figure { font-size: 36px; }
  .hero-unit { font-size: 16px; }
  .seg-bar { height: 22px; }
  .seg { line-height: 22px; font-size: 11px; padding-left: 4px; }
  .legend { flex-direction: column; gap: 6px; }
  .legend li { display: flex; }
  .legend li .muted { margin-left: auto; }
  .num-table { max-width: none; }
  .stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat-tile { padding: 10px 12px; }
  .stat-value { font-size: 20px; }
  .hbars { grid-template-columns: minmax(0, max-content) minmax(24px, 1fr) auto; }
  .hbar-row { gap: 6px; padding: 8px 0; }
  .vbars { height: 130px; gap: 1px; }
  .vbar-label { font-size: 9px; }
  .dash-docs li { padding: 10px 4px; }
}

/* Scanner */
.scan { position: fixed; inset: var(--tb) 0 0 0; z-index: 85; background: #0b0d10; color: #f2f4f7; display: flex; flex-direction: column; }
.scan-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scan button { background: rgba(255,255,255,.1); border-color: transparent; color: #f2f4f7; }
.scan button:hover { border-color: rgba(255,255,255,.35); }
.scan button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.scan button.icon { background: none; color: #d0d5dd; }
.scan button.icon:hover { background: rgba(255,255,255,.1); color: #fff; }
.scan button.icon.danger:hover { color: #f87171; }
.scan input, .scan select { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.18); color: #f2f4f7; }
.scan select option { color: var(--text); background: var(--panel); }
.scan-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
.scan-stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; padding: 8px; overflow: hidden; }
.scan-stage video { width: 100%; height: 100%; object-fit: contain; }
.scan-msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 24px; color: #d0d5dd; }
.scan-msg p { margin: 0; max-width: 420px; }
.scan-msg .button-row { margin-top: 12px; justify-content: center; }
.ico.scan-msg-icon { width: 40px; height: 40px; opacity: .6; }
.scan-flash { position: absolute; inset: 0; background: #fff; animation: scan-flash .18s ease-out forwards; pointer-events: none; }
@keyframes scan-flash { from { opacity: .8; } to { opacity: 0; } }
.scan-controls {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; justify-items: center;
  padding: 14px 20px; padding-bottom: max(14px, env(safe-area-inset-bottom));
}
.scan .shutter {
  width: 72px; height: 72px; border-radius: 50%; padding: 0; background: #fff;
  border: 4px solid rgba(255,255,255,.45); background-clip: padding-box; box-shadow: 0 0 0 2px #fff;
}
.scan .shutter:active { transform: scale(.94); }
.scan .scan-side { width: 52px; height: 52px; border-radius: 12px; padding: 0; position: relative; overflow: visible; }
.scan-side .ico { width: 22px; height: 22px; }
.scan-next img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }
.scan-count {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 5px;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center;
}
.scan-spin {
  display: inline-block; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.25); border-top-color: #fff; animation: spin .7s linear infinite;
}
.scan-pages {
  flex: 1; min-height: 0; overflow-y: auto; display: grid; gap: 12px; padding: 8px 12px 12px; align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.scan-page { background: rgba(255,255,255,.06); border-radius: 10px; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.scan-thumb {
  position: relative; aspect-ratio: 3 / 4; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.35); border-radius: 6px; overflow: hidden; cursor: pointer;
}
.scan-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.scan-nr { position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,.6); border-radius: 6px; padding: 0 6px; font-size: 12px; }
.scan-acts { display: flex; justify-content: space-between; }
.scan-acts .flip { display: inline-flex; transform: rotate(180deg); }
.scan .scan-add { aspect-ratio: 3 / 4; flex-direction: column; border: 2px dashed rgba(255,255,255,.25); background: none; border-radius: 10px; }
.scan .scan-add .ico { width: 36px; height: 36px; }
.scan .scan-add .ico svg { stroke-width: 1.5; }
/* Desktop: weitere Quellen neben dem Scanner */
.scan-add-more { display: flex; flex-direction: column; gap: 8px; justify-content: center; }
.scan-check { display: flex; align-items: center; gap: 6px; color: #d0d5dd; cursor: pointer; }
.scan-foot {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom)); border-top: 1px solid rgba(255,255,255,.1);
}
.scan-foot input { min-width: 160px; font-size: 16px; }
.scan-foot.center-row { justify-content: center; }
.scan-target { width: 100%; color: #98a2b3; }
.scan-crop { position: relative; max-width: 100%; max-height: 100%; }
.scan-crop img { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-select: none; pointer-events: none; }
.scan-crop svg { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; overflow: visible; }
.quad-shade { fill: rgba(0,0,0,.5); }
.quad-line { fill: none; stroke: var(--accent); stroke-width: 2; }
.quad-handle { fill: rgba(37,99,235,.25); stroke: #fff; stroke-width: 2; }
.quad-handle.active { fill: rgba(37,99,235,.55); }
.scan-loupe {
  position: absolute; top: 8px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 4px 16px rgba(0,0,0,.5);
  background-repeat: no-repeat; pointer-events: none; z-index: 2;
}
.scan-loupe::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border: 2px solid var(--accent); border-radius: 50%;
}

/* Titelleiste des Desktop-Clients */
.titlebar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--tb); z-index: 100;
  display: flex; align-items: center; background: var(--panel); border-bottom: 1px solid var(--border);
  user-select: none; -webkit-user-select: none;
}
.tb-brand {
  width: 260px; flex-shrink: 0; display: flex; justify-content: space-between; align-items: center;
  padding: 0 8px 0 16px; font-weight: 700; font-size: 17px; height: 100%; border-right: 1px solid var(--border);
}
.tb-main { flex: 1; min-width: 0; display: flex; gap: 8px; align-items: center; padding: 0 12px; height: 100%; }
.tb-main .search input { padding-top: 7px; padding-bottom: 7px; }
.tb-window { display: flex; height: 100%; }
.tb-btn {
  border: none; border-radius: 0; background: none; width: 46px; height: 100%; padding: 0; color: var(--muted);
}
.tb-btn:hover { background: var(--bg); color: var(--text); }
.tb-btn.close:hover { background: #e81123; color: #fff; }
html.desktop .sidebar .brand { display: none; }

/* Dialoge (statt window.confirm / window.prompt) */
.dialog-bg { z-index: 1000; animation: dialog-fade .12s ease-out; }
.dialog { width: min(440px, 92vw); gap: 12px; padding: 18px 20px 16px; animation: dialog-pop .14s ease-out; }
.dialog-head { display: flex; align-items: center; gap: 8px; }
.dialog-head h3 { flex: 1; margin: 0; font-size: 17px; }
.dialog-text { color: var(--muted); line-height: 1.45; }
.dialog-text p { margin: 0 0 6px; }
.dialog-text p:last-child { margin-bottom: 0; }
.dialog input[type=text], .dialog select { width: 100%; box-sizing: border-box; }
.dialog-check { display: flex !important; flex-direction: row !important; align-items: center; gap: 8px; cursor: pointer; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dialog-actions button { min-width: 96px; }
button.danger-solid { background: var(--danger); color: #fff; border-color: var(--danger); }
button.danger-solid:hover { filter: brightness(1.08); border-color: var(--danger); }
.dialog-menu { display: flex; flex-direction: column; gap: 2px; margin: 0 -8px; }
.dialog-menu button { display: flex; align-items: center; justify-content: flex-start; gap: 10px; width: 100%; text-align: left; white-space: normal; border: none; background: none; padding: 9px 10px; border-radius: 8px; }
.dialog-menu button:hover, .dialog-menu button:focus-visible { background: var(--accent-soft); color: var(--accent); outline: none; }
.dialog-menu button.danger:hover, .dialog-menu button.danger:focus-visible { background: #fde2e2; color: var(--danger); }
.dialog-colors { display: flex; flex-wrap: wrap; gap: 10px; }
.dialog-colors .swatch { width: 34px; height: 34px; padding: 0; border-radius: 50%; background: var(--sw); border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); display: flex; align-items: center; justify-content: center; color: var(--muted); }
.dialog-colors .swatch.none { border: 2px dashed var(--border); box-shadow: none; }
.dialog-colors .swatch.active { outline: 2px solid var(--accent); outline-offset: 2px; }
@keyframes dialog-fade { from { opacity: 0; } }
@keyframes dialog-pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { .dialog-bg, .dialog { animation: none; } }
.sub-toggle { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; color: var(--muted); }

/* Audio und Video */
.kind-audio { color: #db2777; }
.kind-video { color: #7c3aed; }
.thumb { position: relative; }
.thumb-play {
  position: absolute; inset: 0; margin: auto; width: 34px; height: 34px; padding: 0; border-radius: 50%;
  background: var(--accent); color: #fff; border: none; box-shadow: var(--shadow);
  opacity: 0; transition: opacity .12s, transform .12s;
}
.thumb-play .ico { width: 16px; height: 16px; }
.thumb-play .ico svg { fill: currentColor; }
.row:hover .thumb-play, .row.playing .thumb-play, .thumb-play:focus-visible { opacity: 1; }
.thumb-play:hover { transform: scale(1.08); border: none; }
@media (hover: none) { .thumb-play { opacity: 1; } }
.row.playing .title { color: var(--accent); }
.preview.media { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: var(--bg); padding: 16px; box-sizing: border-box; }
.preview.media.audio audio { width: min(100%, 520px); }
.preview.media video { max-width: 100%; max-height: 100%; border-radius: var(--radius); background: #000; }
.ico.media-icon { width: 64px; height: 64px; opacity: .8; }
.ico.media-icon svg { stroke-width: 1.4; }
.player-bar {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 30;
  width: min(560px, calc(100vw - 32px)); display: flex; align-items: center; gap: 10px; padding: 8px 12px;
}
.player-bar .play-btn { width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: #fff; border: none; flex-shrink: 0; }
.player-bar .play-btn .ico svg { fill: currentColor; }
.player-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.player-title { font-weight: 600; font-size: 14px; }
.player-seek { display: flex; align-items: center; gap: 8px; }
.player-seek input[type=range] { flex: 1; accent-color: var(--accent); padding: 0; border: none; }
.layout.has-player .results, .layout.has-player .detail { padding-bottom: 96px; }

/* E-Mails */
.preview.mail { display: flex; flex-direction: column; gap: 12px; overflow: auto; padding: 16px; box-sizing: border-box; background: var(--panel); }
.mail-head { display: flex; flex-direction: column; gap: 3px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.mail-subject { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.mail-h { display: grid; grid-template-columns: 52px 1fr; gap: 8px; font-size: 13px; }
.mail-h span:last-child { overflow-wrap: anywhere; }
.mail-attachments { display: flex; flex-wrap: wrap; gap: 6px; }
.mail-att { max-width: 100%; gap: 6px; font-size: 13px; }
.mail-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; font-size: 14px; }
.mail-thread { border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.mail-thread-head { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; margin-bottom: 4px; color: var(--muted); }
.mail-thread-item { display: flex; justify-content: flex-start; gap: 10px; border: none; background: none; padding: 6px 8px; border-radius: 6px; text-align: left; font-size: 13px; width: 100%; }
.mail-thread-item:hover { background: var(--accent-soft); }
.mail-thread-item.current { background: var(--accent-soft); color: var(--accent); font-weight: 600; cursor: default; }
.mail-thread-from { width: 130px; flex-shrink: 0; }
.mail-parent { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.mail-parent button.link { padding: 0 2px; white-space: normal; text-align: left; }
.bad-text { color: var(--danger); }
.mail-accounts { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.mail-account { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); }
.mail-editor { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; box-shadow: none; }
.mail-editor h4 { margin: 0; }
.mail-grid { display: grid; grid-template-columns: 1fr 90px; gap: 8px 10px; }
.mail-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.mail-grid label:nth-child(n+3) { grid-column: span 2; }
@media (min-width: 560px) {
  .mail-grid { grid-template-columns: 1fr 1fr 90px; }
  .mail-grid label:nth-child(1) { grid-column: span 2; }
  .mail-grid label:nth-child(n+3) { grid-column: auto; }
  .mail-grid label:nth-child(3), .mail-grid label:nth-child(5) { grid-column: span 1; }
  .mail-grid label:nth-child(4), .mail-grid label:nth-child(6) { grid-column: span 2; }
  .mail-grid label.wide { grid-column: 1 / -1; }
}
.mail-folders-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mail-folders { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow: auto; }
.mail-folders li { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; font-size: 13px; }
.mail-folders li.active { background: var(--accent-soft); }
.mail-folders select { max-width: 34%; font-size: 13px; }
.mail-folders li > span.grow { min-width: 90px; }
.mail-progress { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.progress { height: 6px; border-radius: 3px; background: var(--accent-soft); overflow: hidden; position: relative; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s ease; }
.progress.indeterminate .progress-bar { width: 30% !important; position: absolute; animation: progress-slide 1.2s ease-in-out infinite; }
@keyframes progress-slide { from { left: -30%; } to { left: 100%; } }

/* Verknüpfungen */
.row.drop-target { outline: 2px dashed var(--accent); background: var(--accent-soft); }
.parent-ref { align-self: flex-start; justify-content: flex-start; display: inline-flex; align-items: center; gap: 4px; padding: 0; font-size: 12px; white-space: normal; text-align: left; }
.child-toggle { margin-top: 4px; }
.child-toggle > button.link { display: inline-flex; align-items: center; gap: 4px; padding: 2px 0; font-size: 12.5px; }
.child-list { list-style: none; margin: 4px 0 0; padding: 0 0 0 10px; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 1px; }
.child-list li { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.child-list li:hover { background: var(--accent-soft); }
.child-list li.selected { background: var(--accent-soft); color: var(--accent); }
.nowrap { white-space: nowrap; }
.links { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.links-head { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--muted); }
.links-head button.link { text-transform: none; letter-spacing: 0; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; }
.links-group ul { list-style: none; margin: 2px 0 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.link-row { display: flex; align-items: center; gap: 6px; }
.link-open { flex: 1; min-width: 0; justify-content: flex-start; border: none; background: none; padding: 4px 6px; gap: 8px; font-size: 13px; }
.link-open:hover { background: var(--accent-soft); color: var(--accent); }
.link-picker { width: min(520px, 94vw); }
.link-picker input[type=search] { width: 100%; box-sizing: border-box; }
.picker-results { list-style: none; margin: 0; padding: 0; max-height: 300px; min-height: 120px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.picker-results li { display: flex; align-items: center; gap: 8px; padding: 7px 10px; cursor: pointer; font-size: 13px; }
.picker-results li:hover { background: var(--bg); }
.picker-results li.active { background: var(--accent-soft); color: var(--accent); }
.link-picker label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }

/* Sync-Ordner je Sammlung (Desktop) */
.folder-list { list-style: none; padding: 0; margin: 8px 0 12px; display: flex; flex-direction: column; gap: 8px; }
.folder-list li { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.folder-head { display: flex; align-items: center; gap: 6px; }
.folder-head .pill { margin-left: auto; }
.folder-list code { word-break: break-all; }
.pill { font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.pill.ok { color: #1a7f37; border-color: #1a7f37; }
.pill.bad { color: var(--danger); border-color: var(--danger); }
.pill.busy { color: var(--accent); border-color: var(--accent); }

/* Aktivitätsfenster der Sync-Ordner (eigenes Fenster im Desktop-Client) */
.activity-page { height: 100vh; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; box-sizing: border-box; }
.activity-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.activity-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 18px; }
.activity-card { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; box-shadow: none; }
.activity-card code { word-break: break-all; }
.activity-card p { margin: 0; }
.activity-errors { border: 1px solid var(--danger); border-radius: var(--radius); padding: 8px 10px; color: var(--danger); }
.activity-errors ul { margin: 4px 0 0; padding-left: 18px; }
.activity-list { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; border-top: 1px solid var(--border); }
.activity-list li { display: grid; grid-template-columns: 20px auto 1fr; gap: 8px; align-items: start; padding: 5px 0; border-bottom: 1px solid var(--border); }
.activity-icon { color: var(--muted); display: inline-flex; padding-top: 1px; }
.activity-list li.error-text .activity-icon { color: var(--danger); }
.activity-time { white-space: nowrap; font-variant-numeric: tabular-nums; padding-top: 1px; }
.activity-what { display: flex; flex-direction: column; min-width: 0; }
.activity-path { font-weight: 600; word-break: break-all; }
.folder-add { display: flex; flex-direction: column; gap: 8px; }
.folder-add button { align-self: flex-start; }

/* Text- und Markdown-Editor */
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.segmented button { border: none; border-radius: 0; padding: 5px 10px; }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.editor-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr; }
.editor-body.split { grid-template-columns: 1fr 1fr; }
.editor-text {
  width: 100%; height: 100%; box-sizing: border-box; resize: none; border: none; border-radius: 0;
  padding: 16px 20px; font: 14px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  tab-size: 4; background: var(--panel); color: var(--text);
}
.editor-text:focus { outline: none; }
.editor-body.split .editor-text { border-right: 1px solid var(--border); }
.editor-preview { overflow: auto; padding: 16px 28px; min-height: 0; }
.preview.md-view { overflow: auto; padding: 12px 18px; box-sizing: border-box; background: var(--panel); }
@media (max-width: 760px) {
  .editor-body.split { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .editor-body.split .editor-text { border-right: none; border-bottom: 1px solid var(--border); }
}

/* Gerendertes Markdown */
.markdown { line-height: 1.6; word-wrap: break-word; }
.markdown > :first-child { margin-top: 0; }
.markdown h1, .markdown h2 { border-bottom: 1px solid var(--border); padding-bottom: .25em; }
.markdown h1 { font-size: 1.7em; } .markdown h2 { font-size: 1.35em; } .markdown h3 { font-size: 1.15em; }
.markdown a { color: var(--accent); }
.markdown code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9em; background: var(--bg); padding: .1em .35em; border-radius: 4px; }
.markdown pre { background: var(--bg); padding: 10px 12px; border-radius: var(--radius); overflow: auto; }
.markdown pre code { background: none; padding: 0; }
.markdown blockquote { margin: 0; padding: 0 1em; color: var(--muted); border-left: 3px solid var(--border); }
.markdown table { border-collapse: collapse; margin: .5em 0; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 4px 10px; }
.markdown th { background: var(--bg); }
.markdown img { max-width: 100%; }
.markdown ul.contains-task-list, .markdown li:has(> input[type=checkbox]) { list-style: none; }
.markdown li > input[type=checkbox] { margin-right: .4em; }
.markdown hr { border: none; border-top: 1px solid var(--border); }

/* Sammlungen im Baum verschieben */
.section-head.drop-target { outline: 2px dashed var(--accent); background: var(--accent-soft); border-radius: 6px; }
.tree-row[draggable="true"]:active { cursor: grabbing; }

/* Hintergrundaufgaben (Seitenleiste unten) */
.tasks { margin-bottom: 6px; }
.tasks-toggle {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border-radius: 8px;
  color: var(--accent); font-size: 12px; text-align: left; background: transparent; border: 1px solid transparent;
}
.tasks-toggle:hover, .tasks-toggle.open { border-color: var(--border); background: var(--bg); }
.tasks-spin {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite;
}
.tasks-panel {
  position: fixed; left: 8px; bottom: 56px; z-index: 50; width: min(380px, calc(100vw - 16px));
  max-height: 60vh; overflow-y: auto; padding: 10px 12px; color: var(--text); font-size: 13px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.tasks-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.tasks-panel ul { list-style: none; margin: 0; padding: 0; }
.tasks-panel li { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 6px; }
.tasks-panel li.link { cursor: pointer; }
.tasks-panel li.link:hover { background: var(--bg); }
.task-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.task-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-time { flex-shrink: 0; }
.tasks-panel p { margin: 6px 4px 2px; }
