/* ===== Sync & Queue (Topbar-Indikatoren, Queue-Modal, Settings) ===== */

/* Mirror-Sync-Fortschritt in der Topbar */
#sync-indicator {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted);
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 6px 3px 10px; white-space: nowrap;
}
#sync-indicator .si-spin { display: inline-block; animation: si-rotate 1.2s linear infinite; }
@keyframes si-rotate { to { transform: rotate(360deg); } }
#sync-indicator .si-cancel {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  border-radius: 50%; padding: 0 5px; font-size: 12px; line-height: 1.4;
}
#sync-indicator .si-cancel:hover { color: var(--err); background: var(--panel); }

/* Upload-Queue-Badge in der Topbar */
#queue-indicator {
  font-size: 12px; color: var(--text); cursor: pointer; white-space: nowrap;
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 11px; user-select: none;
}
#queue-indicator:hover { border-color: var(--muted); }
#queue-indicator.offline { color: var(--warn); border-color: var(--warn); }
#queue-indicator.has-err { color: var(--err); border-color: var(--err); }

/* Queue-Modal — pro Datei geclustert, aufklappbar */
.uq-list { display: flex; flex-direction: column; gap: 6px; min-height: 60px; }
.uq-empty { color: var(--muted); text-align: center; padding: 18px 0; }

.uq-cluster {
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden;
}
.uq-cluster.uq-active { border-color: var(--accent-dim); }
.uq-cluster.uq-error { border-left: 3px solid var(--err); }

.uq-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.uq-toggle {
  flex-shrink: 0; background: none; border: 0; color: var(--muted);
  cursor: pointer; font-size: 12px; width: 18px; line-height: 1;
  padding: 4px 0; border-radius: 5px;
}
.uq-toggle:hover { color: var(--text); background: var(--panel); }

.uq-info { flex: 1; min-width: 0; cursor: pointer; }
.uq-info:hover .uq-name { color: var(--accent); }
.uq-name { font-weight: 600; font-size: 13px; }
.uq-path { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uq-meta { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.uq-cluster.uq-error .uq-meta { color: var(--err); }

.uq-count {
  flex-shrink: 0; font-size: 10.5px; color: var(--text);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 1px 8px; white-space: nowrap;
}
.uq-actions { display: flex; gap: 2px; flex-shrink: 0; }

/* Aufgeklappte Einzeländerungen */
.uq-children { display: flex; flex-direction: column; background: var(--panel); border-top: 1px solid var(--line); }
.uq-child {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px 7px 28px; border-bottom: 1px solid var(--line);
}
.uq-child:last-child { border-bottom: 0; }
.uq-child.uq-active { background: var(--accent-dim); }
.uq-child-info { flex: 1; min-width: 0; }
.uq-child-desc { font-size: 12.5px; }
.uq-child-detail { color: var(--muted); font-size: 11px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uq-child-meta { color: var(--muted); font-size: 11px; margin-top: 2px; }
.uq-child.uq-error .uq-child-meta { color: var(--err); }

/* ===== Settings-Modal ===== */
.settings .muted { color: var(--muted); font-size: 12.5px; }
.set-sec { border-bottom: 1px solid var(--line); padding: 12px 0 14px; }
.set-sec:last-child { border-bottom: 0; }
.set-sec h3 {
  margin: 0 0 9px; font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.set-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.set-spacer { flex: 1; }
.set-toggle {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  font-size: 13.5px; padding: 3px 0; user-select: none;
}
.set-toggle input { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }

/* Zahlenfeld mit Beschriftung (RAM-Cache-Limits) */
.set-num {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11.5px; color: var(--muted);
}
.set-num .input { width: 100px; }

/* Ordner-Feld mit „Durchsuchen…"-Knopf (Diktat-Speicherort) */
.set-dir-pick { display: flex; gap: 6px; align-items: center; }
.set-dir-pick .input { width: auto; flex: 1; min-width: 120px; }
.set-dir-pick .btn { white-space: nowrap; flex: none; }

/* Fortschrittsbalken (Settings + generisch) */
.set-progress { margin-top: 10px; }
.set-pb {
  height: 7px; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 999px; overflow: hidden;
}
.set-pb-fill {
  height: 100%; width: 0; background: var(--accent);
  border-radius: 999px; transition: width .2s ease;
}
.set-sync-status { margin-top: 5px; font-size: 12.5px; }

/* Statistik-Zeilen (Cache, Speicher) */
.set-stats { margin-top: 10px; }
.set-stat-row {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 12.5px; padding: 3px 0; color: var(--text);
}
.set-stat-row span:last-child { color: var(--muted); }

/* Listen (Freigaben, versteckte Elemente) */
.set-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.set-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; font-size: 13px;
}
.set-item-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Freigaben */
.share-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px;
}
.share-row.share-dead { opacity: .55; }
.share-info { flex: 1; min-width: 0; }
.share-path { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  color: var(--muted); font-size: 11.5px; margin-top: 3px;
}
.share-pill {
  border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px;
  font-size: 10.5px; color: var(--text);
}
.share-pill-rw { border-color: var(--ok); color: var(--ok); }
.share-pill-ro { border-color: var(--accent); color: var(--accent); }
.share-pill-dl { border-color: var(--warn); color: var(--warn); }
.share-actions { display: flex; gap: 2px; flex-shrink: 0; }
.share-revoke:hover { color: var(--err); }

/* Speicher-Übersicht */
.stor-bar {
  display: flex; height: 12px; border-radius: 999px; overflow: hidden;
  background: var(--panel2); border: 1px solid var(--line); margin-top: 8px;
}
.stor-seg { display: block; min-width: 2px; }
.stor-legend {
  display: flex; gap: 14px; flex-wrap: wrap; margin-top: 7px;
  color: var(--muted); font-size: 11.5px;
}
.stor-legend-item { display: flex; align-items: center; gap: 5px; }
.stor-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ===== Start-Sync-Mini-Pille (unten rechts, startup-sync.js) =====
   Bewusst dezent: kleine Pille, gedämpft, halbtransparent, leichter Schatten —
   keine große Karte mehr. Bei Hover etwas präsenter. */
.sync-card {
  position: fixed; right: 14px; bottom: 14px; z-index: 950;
  display: inline-flex; align-items: center; gap: 7px;
  max-width: min(260px, calc(100vw - 28px));
  padding: 5px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 85%, transparent);
  border: 1px solid var(--line); box-shadow: 0 1px 5px rgba(0,0,0,.14);
  font-size: 12px; color: var(--muted); opacity: .82;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: opacity .2s, transform .3s;
}
.sync-card:hover { opacity: 1; }
.sync-card-hide { opacity: 0; transform: translateY(5px); }
.sync-card-status { color: var(--text); white-space: nowrap; }
.sync-card-meta { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sync-card-meta:empty { display: none; }
.sync-card-x {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font-size: 14px; line-height: 1; border-radius: 4px; padding: 0 2px; margin-left: 1px;
}
.sync-card-x:hover { color: var(--text); }
.sync-card-spin {
  width: 11px; height: 11px; flex: 0 0 auto; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: sync-card-spin .8s linear infinite;
}
@keyframes sync-card-spin { to { transform: rotate(360deg); } }

/* ===== Settings-Tabs ===== */
.set-tabs {
  display: flex; gap: 2px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line); margin-bottom: 6px;
}
.set-tab {
  background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); cursor: pointer; padding: 7px 13px; font-size: 13px;
}
.set-tab:hover { color: var(--text); }
.set-tab.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.set-pane { min-height: 220px; }
#set-code-new {
  margin: 8px 0; padding: 9px 12px; border: 1px dashed var(--accent);
  border-radius: 8px; background: var(--accent-dim); font-size: 13.5px;
}

/* ---- Offline-Modus: Banner-Pill + ausgeblendete Schreib-Knöpfe ---- */
#offline-indicator {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--warn); white-space: nowrap;
  background: var(--panel2); border: 1px solid var(--warn);
  border-radius: 999px; padding: 3px 11px; user-select: none;
}
#offline-indicator .oi-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--warn);
  animation: oi-pulse 2s ease-in-out infinite;
}
#offline-indicator.online { color: var(--ok, #22c55e); border-color: var(--ok, #22c55e); }
#offline-indicator.online .oi-dot { background: var(--ok, #22c55e); animation: none; }
@keyframes oi-pulse { 50% { opacity: 0.35; } }
@media (max-width: 768px) { #offline-indicator { font-size: 0; gap: 0; padding: 3px 8px; } }

/* Offline weiterhin aus: Server-Upload und KI-Suche brauchen das Netz.
   #btn-new-note ("+") und der Mobile-FAB bleiben sichtbar — Dateien/Ordner lassen
   sich offline anlegen (gehen in die Upload-Queue, hochladen bei Verbindung). */
body.so-offline #btn-upload,
body.so-offline #btn-ai-search { display: none !important; }
