/* CS-Files – Web-Desktop im DSM-Aufbau, Optik und Tokens aus CS-Dash (Graphit, Akzent #43a5ff).
   Aufbau: Tokens (dunkel + hell) · Grundlagen · gemeinsame Bausteine · Taskleiste · Desktop · Fenster ·
   Menüs/Popover · Dialoge · Toasts · File Station · Aufgaben · schmale Bildschirme. */

/* ===== Tokens ===== */
:root {
  --base: #111214;
  --panel: #191a1d;
  --raised: #222327;
  --field: #141518;
  --border: #303135;
  --border-soft: rgba(255, 255, 255, 0.06);
  --text: #f2f3f5;
  --text-2: #a9abb1;
  --text-3: #74767d;
  --accent: #43a5ff;
  --accent-2: #5bd69b;
  --on-accent: #07121e;
  --ok: #5bd69b;
  --warn: #f5b547;
  --bad: #f87171;
  --info: #43a5ff;
  --radius: 16px;
  --radius-sm: 10px;
  --gap: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  --titlebar: #1c1d21;          /* Hintergrund der Fenster-Titelleiste */
  --titlebar-active: #212227;
  --titlebar-h: 38px;
  --taskbar-h: 44px;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 10px 30px rgba(0, 0, 0, 0.45);
  --hover: rgba(255, 255, 255, 0.06);
  --selected: color-mix(in srgb, var(--accent) 24%, transparent);
  --selected-line: color-mix(in srgb, var(--accent) 55%, transparent);
  --backdrop: rgba(5, 6, 8, 0.55);
  --glass: color-mix(in srgb, var(--panel) 70%, transparent);
  --fi-page: #2b2d33;
  --fi-line: #5d6068;
  color-scheme: dark;
}

/* Hell-Set: per Systemeinstellung (ohne festen Wunsch) oder html[data-theme="light"]. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --base: #e9ecf1;
    --panel: #ffffff;
    --raised: #f2f4f7;
    --field: #ffffff;
    --border: #d6dae1;
    --border-soft: rgba(15, 23, 42, 0.07);
    --text: #191b1f;
    --text-2: #4a4f58;
    --text-3: #7a808a;
    --accent: #1683e8;
    --accent-2: #1fae79;
    --on-accent: #ffffff;
    --ok: #17955d;
    --warn: #b97a06;
    --bad: #d93f3f;
    --info: #1683e8;
    --titlebar: #f3f5f8;
    --titlebar-active: #ffffff;
    --shadow: 0 22px 56px rgba(22, 32, 52, 0.22), 0 2px 8px rgba(22, 32, 52, 0.12);
    --shadow-sm: 0 10px 28px rgba(22, 32, 52, 0.18);
    --hover: rgba(15, 23, 42, 0.05);
    --backdrop: rgba(30, 38, 52, 0.32);
    --fi-page: #ffffff;
    --fi-line: #a7adb7;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --base: #e9ecf1;
  --panel: #ffffff;
  --raised: #f2f4f7;
  --field: #ffffff;
  --border: #d6dae1;
  --border-soft: rgba(15, 23, 42, 0.07);
  --text: #191b1f;
  --text-2: #4a4f58;
  --text-3: #7a808a;
  --accent: #1683e8;
  --accent-2: #1fae79;
  --on-accent: #ffffff;
  --ok: #17955d;
  --warn: #b97a06;
  --bad: #d93f3f;
  --info: #1683e8;
  --titlebar: #f3f5f8;
  --titlebar-active: #ffffff;
  --shadow: 0 22px 56px rgba(22, 32, 52, 0.22), 0 2px 8px rgba(22, 32, 52, 0.12);
  --shadow-sm: 0 10px 28px rgba(22, 32, 52, 0.18);
  --hover: rgba(15, 23, 42, 0.05);
  --backdrop: rgba(30, 38, 52, 0.32);
  --fi-page: #ffffff;
  --fi-line: #a7adb7;
  color-scheme: light;
}

/* ===== Grundlagen ===== */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font: 13px/1.45 var(--font);
  color: var(--text);
  background-color: var(--base);
  background-image:
    radial-gradient(1100px 760px at 0% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    radial-gradient(1000px 760px at 100% 100%, color-mix(in srgb, var(--accent-2) 13%, transparent), transparent 70%),
    radial-gradient(700px 500px at 85% 10%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 70%);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
svg.i { flex-shrink: 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ===== Gemeinsame Bausteine (Vertrag, auch für Teil B) ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 32px; padding: 5px 12px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 13px; white-space: nowrap;
  background: var(--raised); border: 1px solid var(--border); color: var(--text);
  transition: border-color .12s, background .12s;
}
.btn:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.btn:active:not(:disabled) { background: color-mix(in srgb, var(--raised) 80%, var(--text) 6%); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, #fff); border-color: transparent; }
.btn.danger { background: var(--bad); color: #fff; border-color: transparent; }
.btn.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--bad) 88%, #fff); border-color: transparent; }
.btn.icon { padding: 0; width: 32px; min-width: 32px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--hover); color: var(--text); border-color: transparent; }
.btn[aria-pressed="true"] { background: var(--selected); border-color: var(--selected-line); color: var(--text); }
.btn .caret { margin-left: -2px; opacity: .7; }

.input, .select, textarea.input {
  min-height: 32px; padding: 5px 10px; border-radius: var(--radius-sm);
  background: var(--field); border: 1px solid var(--border); color: var(--text); outline: none;
  min-width: 0;
}
textarea.input { padding: 8px 10px; resize: vertical; line-height: 1.45; }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input::placeholder { color: var(--text-3); }
.input:disabled, .select:disabled { opacity: .55; }
.select { padding-right: 28px; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.checkbox input, input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }

.toolbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: nowrap;
  padding: 8px 10px; border-bottom: 1px solid var(--border-soft); min-width: 0;
}
.toolbar .spacer { flex: 1; }
.toolbar .sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; flex-shrink: 0; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  position: sticky; top: 0; z-index: 1; background: var(--panel);
  text-align: left; color: var(--text-3); font-weight: 600; font-size: 11.5px; letter-spacing: .3px;
  padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none;
}
.table th[data-sort], .table th.sortable { cursor: pointer; }
.table th[data-sort]:hover, .table th.sortable:hover { color: var(--text); }
.table th[aria-sort="ascending"]::after { content: " ▲"; font-size: 9px; color: var(--accent); }
.table th[aria-sort="descending"]::after { content: " ▼"; font-size: 9px; color: var(--accent); }
.table td { padding: 7px 10px; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
.table tbody tr:hover td { background: var(--hover); }
.table tr.selected td, .table tr[aria-selected="true"] td { background: var(--selected); }
.table td.num, .table th.num { text-align: right; }

.tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; flex-shrink: 0; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 9px 12px 8px; border: 0; background: none; color: var(--text-2); font-weight: 600;
  border-bottom: 2px solid transparent; white-space: nowrap; border-radius: 0;
}
.tab:hover { color: var(--text); }
.tab.active, .tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

.field { display: grid; gap: 5px; min-width: 0; }
.field > span:first-child, .field > label:first-child { color: var(--text-2); font-size: 12px; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: minmax(120px, max-content) minmax(0, 1fr); gap: 10px 14px; align-items: center; }
.form-grid > label { color: var(--text-2); font-weight: 600; font-size: 12.5px; }
@container (max-width: 480px) { .form-grid { grid-template-columns: minmax(0, 1fr); gap: 4px 0; } .form-grid > label { margin-top: 6px; } }

.muted { color: var(--text-3); }
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: 6px; background: var(--raised); color: var(--text-2);
  letter-spacing: .2px; white-space: nowrap; line-height: 18px;
}
.badge.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.badge.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 15%, transparent); }
.badge.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }
.badge.info { color: var(--info); background: color-mix(in srgb, var(--info) 14%, transparent); }

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  color: var(--text-3); text-align: center; padding: 40px 20px; flex: 1;
}
.empty svg { width: 48px; height: 48px; opacity: .6; }

.split { display: flex; flex: 1; min-height: 0; min-width: 0; }
.split > :not(.sidebar) { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.sidebar {
  width: 220px; flex-shrink: 0; overflow: auto; padding: 8px;
  border-right: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--panel) 60%, var(--base));
}
.list-item {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 30px; padding: 4px 10px;
  border: 0; border-radius: 8px; background: none; color: var(--text); text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-item:hover { background: var(--hover); }
.list-item.active { background: var(--selected); color: var(--text); }
.scroll { overflow: auto; flex: 1; min-height: 0; min-width: 0; }

.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--accent) 22%, transparent); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 5px; border-radius: 99px; background: var(--raised); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--accent); transition: width .25s ease; }
.progress.ok > i { background: var(--ok); }
.progress.bad > i { background: var(--bad); }
.progress.indeterminate > i { width: 35% !important; animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

/* ===== Taskleiste ===== */
.taskbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--taskbar-h); z-index: 9000;
  display: flex; align-items: center; gap: 6px; padding: 0 8px;
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(160%); -webkit-backdrop-filter: blur(22px) saturate(160%);
  border-bottom: 1px solid var(--border-soft);
}
.tb-btn {
  height: 34px; min-width: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 8px; border: 0; border-radius: 9px; background: none; color: var(--text-2); flex-shrink: 0;
}
.tb-btn:hover { background: var(--hover); color: var(--text); }
.tb-btn[aria-expanded="true"] { background: var(--selected); color: var(--text); }
.tb-btn svg.i { width: 18px; height: 18px; }
.tb-start svg.i { width: 20px; height: 20px; }
.tb-wins { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 0 6px; }
.tb-wins::-webkit-scrollbar { display: none; }
.tb-win {
  height: 34px; max-width: 200px; min-width: 0; display: inline-flex; align-items: center; gap: 7px; padding: 0 10px 0 7px;
  border: 1px solid transparent; border-radius: 9px; background: none; color: var(--text-2); flex-shrink: 0;
  position: relative;
}
.tb-win .tb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-win-icon, .tb-icon { display: inline-flex; flex-shrink: 0; }
.tb-win:hover { background: var(--hover); color: var(--text); }
.tb-win.active { background: var(--raised); border-color: var(--border); color: var(--text); }
.tb-win.minimized { opacity: .65; }
.tb-win::after {
  content: ""; position: absolute; left: 50%; bottom: 2px; width: 14px; height: 2px; margin-left: -7px;
  border-radius: 2px; background: var(--text-3);
}
.tb-win.active::after { background: var(--accent); width: 18px; margin-left: -9px; }
.tb-win svg { width: 20px; height: 20px; flex-shrink: 0; }
.tb-tray { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.tb-badges { display: flex; gap: 4px; }
.tb-tasks { position: relative; }
.tb-tasks .ring {
  position: absolute; inset: 4px; border-radius: 50%; pointer-events: none;
  background: conic-gradient(var(--accent) calc(var(--p, 0) * 1turn), transparent 0);
  -webkit-mask: radial-gradient(circle, transparent 11px, #000 11.5px); mask: radial-gradient(circle, transparent 11px, #000 11.5px);
  opacity: 0; transition: opacity .2s;
}
.tb-tasks.busy .ring { opacity: 1; }
.tb-tasks.busy { color: var(--accent); }
.tb-count {
  position: absolute; top: 1px; right: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--accent); color: var(--on-accent); font-size: 10px; font-weight: 800; line-height: 16px; text-align: center;
}
.tb-user { max-width: 180px; }
.tb-user .tb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.tb-clock { padding: 0 6px 0 4px; text-align: right; line-height: 1.1; color: var(--text); font-weight: 600; white-space: nowrap; }
.tb-clock small { display: block; font-size: 10.5px; color: var(--text-3); font-weight: 500; }

/* ===== Desktop ===== */
#desktop {
  position: fixed; top: var(--taskbar-h); left: 0; right: 0; bottom: 0; overflow: hidden;
}
.desk-icons {
  position: absolute; inset: 0; padding: 18px 14px;
  display: grid; grid-auto-flow: column; grid-template-rows: repeat(auto-fill, 108px); grid-auto-columns: 96px;
  gap: 6px; align-content: start; justify-content: start;
}
.desk-icon {
  display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 8px 4px 6px;
  border: 1px solid transparent; border-radius: 12px; background: none; color: var(--text);
  text-align: center; user-select: none; -webkit-user-select: none;
}
.desk-icon svg { width: 54px; height: 54px; filter: drop-shadow(0 4px 10px rgba(0,0,0,.25)); }
.desk-icon-img { display: block; line-height: 0; }
.desk-icon .desk-label {
  font-size: 12px; font-weight: 600; line-height: 1.25; max-width: 88px; padding: 1px 5px; border-radius: 5px;
  text-shadow: 0 1px 2px color-mix(in srgb, var(--base) 80%, transparent);
}
.desk-icon:hover { background: var(--hover); }
.desk-icon:focus-visible, .desk-icon.selected { background: var(--selected); border-color: var(--selected-line); outline: none; }
.desk-error { position: absolute; inset: 0; display: grid; place-content: center; gap: 12px; text-align: center; padding: 20px; }

.snap-preview {
  position: absolute; z-index: 8000; pointer-events: none; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 16%, transparent); border: 2px solid color-mix(in srgb, var(--accent) 70%, transparent);
  transition: all .12s ease;
}

/* ===== Fenster ===== */
.win {
  position: absolute; display: flex; flex-direction: column; min-width: 0;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-sm); overflow: visible; outline: none;
}
.win.active { box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.win.maximized, .win.snap-left, .win.snap-right { border-radius: 0; }
.win.maximized { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; border-width: 0; }
.win.snap-left { left: 0 !important; top: 0 !important; width: 50% !important; height: 100% !important; }
.win.snap-right { left: 50% !important; top: 0 !important; width: 50% !important; height: 100% !important; }
.win-titlebar {
  height: var(--titlebar-h); flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 0 6px 0 12px;
  background: var(--titlebar); border-bottom: 1px solid var(--border-soft); border-radius: 12px 12px 0 0;
  user-select: none; -webkit-user-select: none; touch-action: none; cursor: default;
}
.win.active .win-titlebar { background: var(--titlebar-active); }
.win.maximized .win-titlebar, .win.snap-left .win-titlebar, .win.snap-right .win-titlebar { border-radius: 0; }
.win-titlebar svg.appicon { width: 18px; height: 18px; flex-shrink: 0; }
.win-title { flex: 1; min-width: 0; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.win.active .win-title { color: var(--text); }
.win-ctrls { display: flex; gap: 2px; }
.win-ctrl {
  width: 30px; height: 26px; display: grid; place-items: center; border: 0; border-radius: 7px;
  background: none; color: var(--text-2);
}
.win-ctrl:hover { background: var(--hover); color: var(--text); }
.win-ctrl.close:hover { background: var(--bad); color: #fff; }
.win-ctrl svg { width: 14px; height: 14px; }
.win-body {
  flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; overflow: hidden; position: relative;
  border-radius: 0 0 12px 12px; container-type: inline-size; container-name: win;
}
.win.maximized .win-body, .win.snap-left .win-body, .win.snap-right .win-body { border-radius: 0; }
.win-busy {
  position: absolute; left: 0; right: 0; bottom: 0; top: var(--titlebar-h); z-index: 50; display: grid; place-items: center;
  background: color-mix(in srgb, var(--panel) 55%, transparent); border-radius: 0 0 12px 12px;
}
.win-busy[data-delay] { visibility: hidden; }
.rz { position: absolute; z-index: 60; touch-action: none; }
.rz-n { top: -4px; left: 8px; right: 8px; height: 8px; cursor: ns-resize; }
.rz-s { bottom: -4px; left: 8px; right: 8px; height: 8px; cursor: ns-resize; }
.rz-e { right: -4px; top: 8px; bottom: 8px; width: 8px; cursor: ew-resize; }
.rz-w { left: -4px; top: 8px; bottom: 8px; width: 8px; cursor: ew-resize; }
.rz-ne { right: -5px; top: -5px; width: 14px; height: 14px; cursor: nesw-resize; }
.rz-sw { left: -5px; bottom: -5px; width: 14px; height: 14px; cursor: nesw-resize; }
.rz-nw { left: -5px; top: -5px; width: 14px; height: 14px; cursor: nwse-resize; }
.rz-se { right: -5px; bottom: -5px; width: 14px; height: 14px; cursor: nwse-resize; }
.win.maximized .rz, .win.snap-left .rz, .win.snap-right .rz, .win.fixed .rz { display: none; }
body.wm-dragging, body.wm-dragging * { user-select: none !important; -webkit-user-select: none !important; }
body.wm-dragging iframe { pointer-events: none; }

/* ===== Menüs und Popover ===== */
.menu {
  position: fixed; z-index: 15000; min-width: 200px; max-width: min(340px, calc(100vw - 16px)); padding: 5px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  overflow-y: auto; outline: none;
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 30px; padding: 4px 10px 4px 8px;
  border: 0; border-radius: 7px; background: none; color: var(--text); text-align: left; white-space: nowrap;
}
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--accent); color: var(--on-accent); outline: none; }
.menu-item:disabled { opacity: .4; cursor: default; }
.menu-item.danger { color: var(--bad); }
.menu-item.danger:hover:not(:disabled), .menu-item.danger:focus-visible { background: var(--bad); color: #fff; }
.menu-ic { width: 16px; height: 16px; display: grid; place-items: center; flex-shrink: 0; opacity: .85; }
.menu-ic svg { width: 16px; height: 16px; }
.menu-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.menu-key { color: var(--text-3); font-size: 11.5px; margin-left: 16px; }
.menu-item:hover:not(:disabled) .menu-key, .menu-item:focus-visible .menu-key { color: inherit; opacity: .8; }
.menu-sep { height: 1px; margin: 5px 6px; background: var(--border); }
.menu-header { padding: 8px 10px 6px; }
.menu-header strong { display: block; font-size: 13.5px; }
.menu-header small { display: block; color: var(--text-3); font-size: 12px; }

.popover {
  position: fixed; z-index: 15000; background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); outline: none; max-width: calc(100vw - 16px);
}
.start-menu {
  left: 8px; top: calc(var(--taskbar-h) + 6px); width: min(560px, calc(100vw - 16px));
  max-height: calc(100dvh - var(--taskbar-h) - 20px); display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(26px) saturate(160%); -webkit-backdrop-filter: blur(26px) saturate(160%);
}
.start-search { margin: 14px 14px 6px; display: flex; }
.start-search .input { flex: 1; min-height: 36px; padding-left: 34px; background-repeat: no-repeat; }
.start-search { position: relative; }
.start-search svg { position: absolute; left: 11px; top: 10px; color: var(--text-3); pointer-events: none; }
.start-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; padding: 8px 14px 16px; overflow-y: auto; }
.start-tile {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 6px 10px; border: 1px solid transparent;
  border-radius: 12px; background: none; color: var(--text); font-weight: 600; font-size: 12.5px; text-align: center;
}
.start-tile svg { width: 46px; height: 46px; }
.start-tile:hover, .start-tile:focus-visible { background: var(--hover); border-color: var(--border); outline: none; }
.start-empty { padding: 20px; text-align: center; color: var(--text-3); grid-column: 1 / -1; }

/* ===== Dialoge ===== */
.dialog-backdrop {
  position: fixed; inset: 0; z-index: 20000; display: grid; place-items: center; padding: 16px;
  background: var(--backdrop);
  animation: fade .12s ease;
}
.dialog-backdrop.in-window { position: absolute; top: var(--titlebar-h); z-index: 70; border-radius: 0 0 12px 12px; }
.dialog {
  width: min(480px, 100%); max-height: calc(100% - 8px); display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); outline: none;
  animation: pop .14s ease;
}
.dialog-head { padding: 16px 18px 4px; font-size: 15px; font-weight: 700; margin: 0; }
.dialog-body { padding: 6px 18px 14px; overflow: auto; display: grid; gap: 12px; }
.dialog-msg { margin: 0; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.dialog-body .input { width: 100%; }
.dialog-error { color: var(--bad); font-size: 12px; min-height: 1em; margin: -6px 0 0; }
.dialog-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--border-soft); }
.dialog-foot .checkbox { margin-right: auto; color: var(--text-2); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(4px); } }

/* ===== Toasts ===== */
.toasts {
  position: fixed; top: calc(var(--taskbar-h) + 10px); right: 12px; z-index: 30000;
  display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 24px)); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 10px 8px 10px 12px;
  background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--info);
  border-radius: 11px; box-shadow: var(--shadow-sm); animation: toastIn .18s ease;
}
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
.toast.bad { border-left-color: var(--bad); }
.toast-msg { flex: 1; min-width: 0; overflow-wrap: anywhere; padding-top: 2px; }
.toast .btn.icon { width: 24px; min-width: 24px; min-height: 24px; border: 0; background: none; color: var(--text-3); }
.toast.leaving { opacity: 0; transform: translateX(20px); transition: all .2s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } }

/* ===== File Station ===== */
.fs { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.fs-bar { gap: 4px; }
.fs-bar .btn.icon { width: 30px; min-width: 30px; min-height: 30px; }
.fs-crumbs {
  flex: 1; min-width: 60px; display: flex; align-items: center; gap: 1px; height: 32px; padding: 0 4px;
  background: var(--field); border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow-x: auto; scrollbar-width: none; white-space: nowrap;
}
.fs-crumbs::-webkit-scrollbar { display: none; }
.fs-crumb {
  border: 0; background: none; padding: 3px 7px; border-radius: 6px; color: var(--text-2); font-weight: 600; flex-shrink: 0;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis;
}
.fs-crumb:hover { background: var(--hover); color: var(--text); }
.fs-crumb:last-child { color: var(--text); }
.fs-crumb.drop-target { background: var(--selected); }
.fs-crumb-sep { color: var(--text-3); display: inline-flex; flex-shrink: 0; }
.fs-crumb-sep svg { width: 12px; height: 12px; }
.fs-search { position: relative; width: 200px; flex-shrink: 1; min-width: 110px; }
.fs-search .input { width: 100%; padding-left: 30px; }
.fs-search svg { position: absolute; left: 10px; top: 9px; color: var(--text-3); pointer-events: none; }
.fs-actions { padding-top: 6px; }
.fs-split { flex: 1; min-height: 0; position: relative; }
.fs-tree { width: 220px; padding: 6px; }
.fs-tree-head { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .7px; padding: 10px 8px 4px; }
.tree-row {
  display: flex; align-items: center; gap: 4px; min-height: 28px; padding: 0 6px 0 calc(var(--depth, 0) * 14px + 2px);
  border-radius: 7px; cursor: pointer; white-space: nowrap; user-select: none; outline: none;
}
.tree-row:hover { background: var(--hover); }
.tree-row.active { background: var(--selected); }
.tree-row:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.tree-row.drop-target { background: var(--selected); box-shadow: inset 0 0 0 1px var(--selected-line); }
.tree-twisty {
  width: 18px; height: 18px; display: grid; place-items: center; border: 0; background: none; color: var(--text-3); padding: 0;
  border-radius: 4px; flex-shrink: 0; transition: transform .12s;
}
.tree-twisty svg { width: 12px; height: 12px; }
.tree-twisty.open { transform: rotate(90deg); }
.tree-twisty.leaf { visibility: hidden; }
.tree-row .ficon, .tree-row svg.i { width: 17px; height: 17px; flex-shrink: 0; }
.tree-row svg.i { color: var(--accent); }
.tree-label { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tree-row .badge { margin-left: auto; font-size: 9.5px; padding: 0 5px; line-height: 15px; }
.fs-main { position: relative; }
.fs-search-info { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: color-mix(in srgb, var(--accent) 10%, var(--panel)); border-bottom: 1px solid var(--border-soft); font-size: 12.5px; }
.fs-search-info .fs-search-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fs-search-info svg { color: var(--accent); display: block; }
.fs-head, .fs-row {
  display: grid; align-items: center;
  grid-template-columns: minmax(180px, 1fr) 86px 140px 140px 96px 104px;
}
.fs.search .fs-head, .fs.search .fs-row { grid-template-columns: minmax(160px, 1fr) minmax(120px, .8fr) 86px 140px 96px 104px; }
.fs-head {
  position: sticky; top: 0; z-index: 2; background: var(--panel); border-bottom: 1px solid var(--border);
  min-width: 640px;
}
.fs-head button {
  display: flex; align-items: center; gap: 4px; height: 30px; padding: 0 10px; border: 0; background: none;
  color: var(--text-3); font-weight: 600; font-size: 11.5px; letter-spacing: .3px; text-align: left; white-space: nowrap; overflow: hidden;
}
.fs-head button:hover { color: var(--text); }
.fs-head button[aria-sort="ascending"]::after { content: "▲"; font-size: 8px; color: var(--accent); }
.fs-head button[aria-sort="descending"]::after { content: "▼"; font-size: 8px; color: var(--accent); }
.fs-head .num { justify-content: flex-end; }
.fs-list {
  position: relative; flex: 1; min-height: 0; overflow: auto; outline: none; user-select: none; -webkit-user-select: none;
}
.fs-items { outline: none; }
.fs-items:focus-visible { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 8px; }
.fs-items { min-width: 640px; padding: 2px 4px 30px; min-height: calc(100% - 31px); }
.fs-row {
  min-height: 30px; border-radius: 7px; border: 1px solid transparent; cursor: default; content-visibility: auto; contain-intrinsic-size: auto 30px;
}
.fs-row > span { padding: 0 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.fs-row > .fs-name { display: flex; align-items: center; gap: 8px; color: var(--text); }
.fs-name span { overflow: hidden; text-overflow: ellipsis; }
.fs-row > .num { text-align: right; }
.fs-row .mono { font-family: var(--mono); font-size: 11.5px; }
.fs-row:hover { background: var(--hover); }
.fs-item[aria-selected="true"] { background: var(--selected); }
.fs-item.cursor { border-color: var(--selected-line); }
.fs-items:not(:focus) .fs-item.cursor:not([aria-selected="true"]) { border-color: transparent; }
.fs-item.cut { opacity: .5; }
.fs-item.drop-target { background: var(--selected); border-color: var(--accent); }
.fs-ficon { display: inline-flex; flex-shrink: 0; }
.fs-path-link { border: 0; background: none; padding: 0; color: var(--accent); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.fs-path-link:hover { text-decoration: underline; }
.fs.grid .fs-head { display: none; }
.fs.grid .fs-items { min-width: 0; min-height: 100%; display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; padding: 10px; align-content: start; }
.fs-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px 8px; border-radius: 10px;
  border: 1px solid transparent; text-align: center; min-width: 0;
}
.fs-tile:hover { background: var(--hover); }
.fs-tile .ficon { width: 52px; height: 52px; }
.fs-tile .fs-tile-name {
  font-size: 12px; line-height: 1.3; max-width: 100%; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.fs-tile .fs-tile-sub { font-size: 11px; color: var(--text-3); }
.fs-empty { position: absolute; inset: 31px 0 0; pointer-events: none; }
.fs.grid .fs-empty { inset: 0; }
.fs-band { position: absolute; z-index: 5; pointer-events: none; border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); border-radius: 3px; }
.fs-list.drop-target { box-shadow: inset 0 0 0 2px var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.fs-status {
  display: flex; align-items: center; gap: 10px; padding: 4px 12px; min-height: 26px; flex-shrink: 0;
  border-top: 1px solid var(--border-soft); color: var(--text-3); font-size: 12px; white-space: nowrap; overflow: hidden;
}
.fs-status .spacer { flex: 1; }
.fs-tree-toggle { display: none !important; }
.fs-ro .badge { margin-left: 4px; }

/* File Station in schmalen Fenstern: Spalten sparen, Baum als Schublade */
@container win (max-width: 820px) {
  .fs-head, .fs-row { grid-template-columns: minmax(160px, 1fr) 80px 136px; }
  .fs.search .fs-head, .fs.search .fs-row { grid-template-columns: minmax(140px, 1fr) minmax(100px, .8fr) 80px; }
  .fs-row > :nth-child(n+4), .fs-head > :nth-child(n+4) { display: none; }
  .fs-head, .fs-items { min-width: 0; }
  .fs-search { width: 150px; }
}
@container win (max-width: 620px) {
  .fs-tree-toggle { display: inline-flex !important; }
  .fs-tree { position: absolute; z-index: 20; top: 0; bottom: 0; left: 0; width: 240px; box-shadow: var(--shadow-sm); background: var(--panel); }
  .fs-tree:not(.open) { display: none; }
  .fs-head, .fs-row { grid-template-columns: minmax(120px, 1fr) 76px; }
  .fs.search .fs-head, .fs.search .fs-row { grid-template-columns: minmax(120px, 1fr) minmax(80px, .7fr); }
  .fs-row > :nth-child(n+3), .fs-head > :nth-child(n+3) { display: none; }
  .fs-bar .fs-hide-narrow { display: none; }
  .fs-search { width: 120px; min-width: 90px; }
  .fs-actions .btn-label { display: none; }
}

/* ===== Aufgaben ===== */
.tasks { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.tasks .toolbar { flex-wrap: wrap; }
.tasks-list { padding: 4px 12px 14px; }
.tasks-sec { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .7px; padding: 12px 2px 6px; display: flex; gap: 8px; align-items: center; }
.task-row { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--border-soft); }
.task-row .ficon, .task-row svg.i { width: 20px; height: 20px; }
.task-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-sub { font-size: 11.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-sub.bad { color: var(--bad); }
.task-sub.ok { color: var(--ok); }
.task-ic { grid-column: 1; grid-row: 1 / span 3; align-self: start; padding-top: 1px; line-height: 0; }
.task-name, .task-sub, .task-row .progress { grid-column: 2; }
.task-row .btn.icon { width: 28px; min-width: 28px; min-height: 28px; grid-column: 3; grid-row: 1 / span 3; }
.task-pop { width: 340px; padding: 12px; display: grid; gap: 10px; }
.task-pop-head { display: flex; align-items: center; gap: 8px; }
.task-pop-head strong { flex: 1; }
.task-pop-list { display: grid; gap: 10px; max-height: 300px; overflow: auto; }
.task-pop-item { display: grid; gap: 4px; }
.task-pop-item .row { display: flex; gap: 8px; font-size: 12.5px; }
.task-pop-item .row span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-pop-item .row span:last-child { color: var(--text-3); }

/* ===== Schmale Bildschirme (< 700 px): Fenster immer maximiert ===== */
html.compact .win {
  left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important;
  border-radius: 0; border-width: 0;
}
html.compact .win-titlebar, html.compact .win-body, html.compact .win-busy, html.compact .dialog-backdrop.in-window { border-radius: 0; }
html.compact .rz, html.compact .win-ctrl.max { display: none; }
@media (max-width: 699px) {
  .tb-label, .tb-clock small { display: none; }
  .tb-win { padding: 0 8px; }
  .tb-badges .badge { max-width: 64px; overflow: hidden; text-overflow: ellipsis; }
  .tb-clock { font-size: 12px; }
  .desk-icons { grid-auto-flow: row; grid-template-rows: none; grid-template-columns: repeat(auto-fill, 90px); grid-auto-columns: auto; overflow-y: auto; justify-content: center; }
  .dialog-foot .btn { flex: 1; }
}
@media (max-width: 420px) {
  .tb-clock { display: none; }
  .tb-badges .badge { display: none; }
  .tb-badges .badge:first-child { display: inline-flex; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition: none !important; }
}
