/* ================================================================ Tokens */
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --surface-3: #e6e9f1;
  --border: #e2e5ee;
  --text: #171a23;
  --muted: #646b7e;
  --accent: #4f46e5;
  --accent-2: #6366f1;
  --accent-soft: #eef0ff;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --success: #16a34a;
  --success-soft: #e8f7ee;
  --warn: #d97706;
  --shadow-sm: 0 1px 2px rgba(20, 24, 40, .06);
  --shadow: 0 8px 28px rgba(20, 24, 40, .10);
  --shadow-lg: 0 24px 64px rgba(20, 24, 40, .22);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar: 260px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1016; --surface: #161922; --surface-2: #1c2030; --surface-3: #252a3b; --border: #272c3d;
    --text: #e8eaf2; --muted: #9097ab; --accent: #818cf8; --accent-2: #a5b4fc; --accent-soft: #23264a; --accent-text: #0e1016;
    --danger: #f87171; --danger-soft: #3a1c1f; --success: #4ade80; --success-soft: #16301f;
    --shadow: 0 8px 28px rgba(0, 0, 0, .45); --shadow-lg: 0 24px 64px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1016; --surface: #161922; --surface-2: #1c2030; --surface-3: #252a3b; --border: #272c3d;
  --text: #e8eaf2; --muted: #9097ab; --accent: #818cf8; --accent-2: #a5b4fc; --accent-soft: #23264a; --accent-text: #0e1016;
  --danger: #f87171; --danger-soft: #3a1c1f; --success: #4ade80; --success-soft: #16301f;
  --shadow: 0 8px 28px rgba(0, 0, 0, .45); --shadow-lg: 0 24px 64px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ================================================================ Basis */
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
[data-icon] { display: inline-flex; align-items: center; justify-content: center; }

/* ================================================================ Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 550; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13.5px; border-radius: 8px; }
.btn.block { width: 100%; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 8px; }
.icon-btn.sm svg.i { width: 16px; height: 16px; }
.link { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 6px 0; }

/* ================================================================ Formulare */
label { display: grid; gap: 6px; font-size: 13.5px; font-weight: 550; color: var(--muted); }
input, select, textarea { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input[type="checkbox"], input[type="radio"] { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); box-shadow: none; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; color: var(--text); cursor: pointer; }
.hint { font-size: 13px; color: var(--muted); font-weight: 400; margin: -2px 0 0; }
.form { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.radio-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.radio-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1.5px solid var(--border); border-radius: 12px; cursor: pointer; color: var(--text); font-weight: 500; }
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio-card small { display: block; color: var(--muted); font-weight: 400; }

/* ================================================================ Anmeldung */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
  radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, #06b6d4 18%, transparent), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 410px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 32px; box-shadow: var(--shadow-lg); }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; margin-bottom: 22px; }
.auth-form { display: grid; gap: 14px; }
.auth-form h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.auth-form p { margin: -6px 0 4px; }
.auth-msg { min-height: 20px; margin: 14px 0 0; font-size: 14px; color: var(--danger); }
.auth-msg.ok { color: var(--success); }
.logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), #06b6d4); color: #fff; }
.logo svg.i { width: 19px; height: 19px; }

/* ================================================================ Layout */
.app { display: flex; height: 100%; }
.sidebar { width: var(--sidebar); flex: none; display: flex; flex-direction: column; gap: 6px; padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; font-weight: 700; font-size: 16px; }
.nav { display: grid; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; height: 40px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; font-weight: 550; color: var(--muted); text-align: left; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-section { margin-top: 14px; }
.nav-section-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 4px 12px; font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.service-nav { display: grid; gap: 2px; }
.service-item { display: flex; align-items: center; border-radius: 10px; }
.service-item:hover { background: var(--surface-2); }
.service-item.active { background: var(--accent-soft); }
.service-item > button:first-child { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; height: 38px; padding: 0 12px; border: 0; background: none; cursor: pointer; color: var(--text); text-align: left; }
.service-item > button:first-child span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.service-item .icon-btn { opacity: 0; }
.service-item:hover .icon-btn, .service-item:focus-within .icon-btn { opacity: 1; }
.favicon { width: 18px; height: 18px; border-radius: 5px; flex: none; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 12px 4px 0; border-top: 1px solid var(--border); }
.me { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.me > div { min-width: 0; }
.avatar { width: 36px; height: 36px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.me-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-mail { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; }
.topbar { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 24px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(8px); }
.topbar h2 { margin: 0; font-size: 19px; letter-spacing: -.01em; }
.context-banner { display: flex; align-items: center; gap: 10px; padding: 5px 6px 5px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 14px; }
.view { flex: 1; min-height: 0; overflow: auto; padding: 24px; }
.view.flush { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.mobile-only { display: none; }
.scrim { display: none; }

/* ================================================================ Karten & Listen */
.page { max-width: 980px; margin: 0 auto; display: grid; gap: 20px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h3 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.card h4 { margin: 0 0 14px; font-size: 16px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.tile { display: flex; flex-direction: column; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.tile-head { display: flex; align-items: center; gap: 12px; }
.tile-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.tile-title { font-weight: 650; }
.tile-sub { font-size: 13px; color: var(--muted); word-break: break-all; }
.tile-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.status-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-dot.ok { color: var(--success); } .status-dot.ok::before { background: var(--success); }
.status-dot.err { color: var(--danger); } .status-dot.err::before { background: var(--danger); }
.empty { display: grid; place-items: center; gap: 10px; padding: 48px 16px; text-align: center; color: var(--muted); }
.empty .tile-icon { width: 56px; height: 56px; border-radius: 16px; }
.empty .tile-icon svg.i { width: 26px; height: 26px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: 0; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--muted); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* ================================================================ Dateimanager */
.panes { flex: 1; min-height: 0; display: flex; gap: 0; }
.panes.dual { display: grid; grid-template-columns: 1fr auto 1fr; }
.pane { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--surface); position: relative; container-type: inline-size; }
.panes.dual .pane { border-right: 1px solid var(--border); }
.panes.dual .pane:last-child { border-right: 0; border-left: 1px solid var(--border); }
.pane-head { display: grid; gap: 10px; padding: 14px 18px 10px; border-bottom: 1px solid var(--border); }
.storage-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.storage-chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 13px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); cursor: pointer; font-weight: 550; font-size: 14px; white-space: nowrap; color: var(--muted); }
.chip:hover { color: var(--text); background: var(--surface-2); }
.chip.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip svg.i { width: 16px; height: 16px; }
.pane-bar { display: flex; align-items: center; gap: 8px; }
.crumbs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.crumbs::-webkit-scrollbar { display: none; }
.crumb { border: 0; background: none; padding: 5px 8px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 550; white-space: nowrap; }
.crumb:hover { background: var(--surface-2); color: var(--text); }
.crumb:last-child { color: var(--text); }
.crumb.drop-hover { background: var(--accent-soft); color: var(--accent); }
.crumb-sep { color: var(--muted); opacity: .6; display: inline-flex; }
.crumb-sep svg.i { width: 14px; height: 14px; }
.pane-tools { display: flex; gap: 4px; }
.selbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px 14px; background: var(--accent-soft); border-bottom: 1px solid var(--border); }
.selbar .count { font-weight: 650; color: var(--accent); margin-right: 6px; padding-left: 4px; }
.selbar .btn { background: var(--surface); }
.list { flex: 1; min-height: 0; overflow: auto; position: relative; }
.list-head, .row { display: grid; grid-template-columns: 40px minmax(0, 1fr) 96px 140px 44px; align-items: center; gap: 4px; padding: 0 10px; }
.list-head { position: sticky; top: 0; z-index: 1; height: 38px; font-size: 12.5px; font-weight: 600; color: var(--muted); background: var(--surface); border-bottom: 1px solid var(--border); }
.list-head button { border: 0; background: none; color: inherit; font: inherit; cursor: pointer; text-align: left; padding: 0; }
.row { height: 50px; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); cursor: default; user-select: none; }
.row:hover { background: var(--surface-2); }
.row.selected { background: var(--accent-soft); }
.row.drop-hover { background: var(--accent-soft); outline: 2px dashed var(--accent); outline-offset: -2px; }
.row .cell-check { display: grid; place-items: center; }
.row .name { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row .name button { border: 0; background: none; padding: 0; cursor: pointer; text-align: left; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: var(--text); }
.row .name button:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.row .size, .row .date { font-size: 13.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ficon { width: 34px; height: 34px; flex: none; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.ficon.folder { background: color-mix(in srgb, #f59e0b 18%, transparent); color: #d97706; }
.ficon.image { background: color-mix(in srgb, #ec4899 15%, transparent); color: #db2777; }
.ficon.video { background: color-mix(in srgb, #8b5cf6 16%, transparent); color: #7c3aed; }
.ficon.audio { background: color-mix(in srgb, #06b6d4 16%, transparent); color: #0891b2; }
.ficon.pdf { background: color-mix(in srgb, #ef4444 15%, transparent); color: #dc2626; }
.ficon.archive { background: color-mix(in srgb, #84cc16 18%, transparent); color: #65a30d; }
.ficon.doc { background: color-mix(in srgb, #3b82f6 15%, transparent); color: #2563eb; }
.ficon svg.i { width: 18px; height: 18px; }
.list .empty { padding-top: 64px; }
.drop-overlay { position: absolute; inset: 8px; z-index: 5; display: none; place-items: center; border: 2px dashed var(--accent); border-radius: 14px; background: color-mix(in srgb, var(--accent-soft) 85%, transparent); color: var(--accent); font-weight: 650; pointer-events: none; }
.pane.dragging .drop-overlay { display: grid; }
.pane-foot { padding: 8px 18px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--border); display: flex; gap: 12px; }
.loading-bar { position: absolute; left: 0; right: 0; top: 0; height: 2px; overflow: hidden; }
.loading-bar::after { content: ""; position: absolute; inset: 0; width: 40%; background: var(--accent); animation: load 1s ease-in-out infinite; }
@keyframes load { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
.pane-error { margin: 18px; padding: 14px 16px; border-radius: 12px; background: var(--danger-soft); color: var(--danger); display: grid; gap: 10px; justify-items: start; white-space: pre-line; }

.transfer-mid { display: flex; flex-direction: column; justify-content: center; gap: 10px; padding: 16px 12px; background: var(--bg); }
.transfer-mid .btn { width: 132px; justify-content: flex-start; padding: 0 12px; }
.transfer-mid .label { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); text-align: center; margin-top: 6px; }
.transfer-intro { padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 14px; display: flex; gap: 10px; align-items: center; }

/* ================================================================ Dienst (iframe) */
.frame-bar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--border); background: var(--surface); font-size: 14px; }
.frame-bar .url { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frame { flex: 1; width: 100%; border: 0; background: #fff; }

/* ================================================================ Dialoge & Menues */
.modal-back { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(10, 12, 20, .45); backdrop-filter: blur(3px); animation: fade .15s; }
.modal { width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); animation: pop .18s cubic-bezier(.2, .9, .3, 1.2); }
.modal.wide { max-width: 720px; }
.modal.preview { max-width: min(1100px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 0; }
.modal-head h3 { margin: 0; font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 16px 20px; display: grid; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 20px 20px; flex-wrap: wrap; }
.modal-msg { font-size: 14px; color: var(--danger); min-height: 0; white-space: pre-line; }
.modal-msg.ok { color: var(--success); }
.preview-body { display: grid; place-items: center; background: var(--surface-2); min-height: 200px; }
.preview-body img, .preview-body video { max-width: 100%; max-height: calc(100vh - 190px); display: block; }
.preview-body iframe { width: 100%; height: calc(100vh - 190px); border: 0; background: #fff; }
.modal.preview .modal-body { padding: 12px 0; }
.preview-body audio { width: 90%; margin: 40px 0; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.menu { position: fixed; z-index: 60; min-width: 210px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); animation: fade .1s; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: none; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 5px 0; }
.picker { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.picker .crumbs { padding: 8px; border-bottom: 1px solid var(--border); }
.picker-list { height: 260px; overflow: auto; }
.picker-list button { display: flex; align-items: center; gap: 10px; width: 100%; height: 42px; padding: 0 12px; border: 0; background: none; cursor: pointer; text-align: left; border-bottom: 1px solid var(--border); }
.picker-list button:hover { background: var(--surface-2); }
.picker-list .empty { padding: 40px 10px; }

/* ================================================================ Aufgaben & Hinweise */
.tasks { position: fixed; right: 16px; bottom: 16px; z-index: 40; width: 360px; max-width: calc(100vw - 32px); max-height: 50vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); }
.tasks-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 10px 16px; font-weight: 650; background: var(--surface); border-bottom: 1px solid var(--border); }
.task { padding: 12px 16px; border-bottom: 1px solid var(--border); display: grid; gap: 6px; }
.task:last-child { border-bottom: 0; }
.task-top { display: flex; align-items: center; gap: 8px; }
.task-title { flex: 1; min-width: 0; font-weight: 550; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-status { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task.error .task-status { color: var(--danger); white-space: normal; }
.task.done .task-status { color: var(--success); }
.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > div { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent), #06b6d4); transition: width .3s; }
.task.done .progress > div { background: var(--success); }
.task.error .progress > div { background: var(--danger); }
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; max-width: min(520px, calc(100vw - 32px)); padding: 11px 16px; border-radius: 12px; background: var(--text); color: var(--surface); box-shadow: var(--shadow); font-size: 14px; animation: pop .2s; white-space: pre-line; }
.toast.error { background: var(--danger); color: #fff; }

/* ================================================================ Touch & Handy
   Richtlinien: iOS Human Interface Guidelines (Tab Bar, Action Sheets, 44 pt
   Touch-Ziele, Sicherheitsbereiche) und Material Design 3 (Navigation Bar,
   Bottom Sheets, 48 dp Touch-Ziele, FAB). */

/* Basis für alle Touch-Geräte */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
button, a, .row, .chip, .nav-item, .tabbar button { touch-action: manipulation; }
.list, .view, .picker-list, .sheet, .modal { overscroll-behavior: contain; }
@supports (height: 100dvh) { .app { height: 100dvh; } }

/* Zusatzelemente: am Desktop unsichtbar */
.tabbar, .fab, .seg, .mbar { display: none; }
.row .name-text { min-width: 0; display: flex; flex-direction: column; }
.row .sub { display: none; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Bottom Sheet (Aktionsmenü auf dem Handy) */
.sheet-back { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; background: rgba(10, 12, 20, .42); animation: fade .15s; }
.sheet { width: 100%; max-width: 560px; max-height: 82dvh; overflow: auto; background: var(--surface); border-radius: 20px 20px 0 0; padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg); animation: sheet-up .24s cubic-bezier(.2, .8, .2, 1); }
.sheet::before { content: ""; display: block; width: 36px; height: 5px; margin: 2px auto 8px; border-radius: 3px; background: var(--surface-3); }
.sheet-title { padding: 4px 12px 10px; font-size: 13px; font-weight: 600; color: var(--muted); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet button { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 52px; padding: 0 14px; border: 0; border-radius: 12px; background: none; font-size: 17px; text-align: left; cursor: pointer; }
.sheet button:active { background: var(--surface-2); }
.sheet button.danger { color: var(--danger); }
.sheet button svg.i { width: 22px; height: 22px; color: var(--muted); }
.sheet button.danger svg.i { color: var(--danger); }
.sheet hr { border: 0; border-top: 1px solid var(--border); margin: 6px 4px; }
.sheet .sheet-cancel { justify-content: center; margin-top: 6px; background: var(--surface-2); font-weight: 600; color: var(--accent); }
[data-platform="android"] .sheet .sheet-cancel { display: none; }
[data-platform="android"] .sheet-title { text-align: left; }
@keyframes sheet-up { from { transform: translateY(100%); } }

/* Große Touch-Ziele (iOS 44 pt / Android 48 dp) auf allen Touch-Geräten */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn.sm { min-height: 40px; }
  .icon-btn, .icon-btn.sm { width: 44px; height: 44px; }
  .icon-btn.sm svg.i { width: 20px; height: 20px; }
  input, select { height: 48px; font-size: 16px; } /* 16 px verhindert das automatische Hineinzoomen von iOS */
  textarea { font-size: 16px; }
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; }
  .chip { height: 40px; }
  .crumb { min-height: 40px; padding: 0 10px; }
  .row { height: 60px; }
  .list-head { height: 44px; }
  .service-item .icon-btn { opacity: 1; }
  .row, .list-head button { -webkit-touch-callout: none; }
}

/* Spalten nach Breite des jeweiligen Dateifensters (auch im Doppelfenster) */
@container (max-width: 640px) {
  .list-head, .row { grid-template-columns: 44px minmax(0, 1fr) 80px 48px; }
  .list-head .date, .row .date { display: none; }
}
@container (max-width: 480px) {
  .list-head, .row { grid-template-columns: 44px minmax(0, 1fr) 48px; padding: 0 4px; }
  .list-head .size, .row .size { display: none; }
  .row .sub { display: block; }
  .row .name button { line-height: 1.25; }
}

/* Schmale Desktop-Fenster: Mittelspalte der Übertragen-Ansicht kompakter */
@media (max-width: 1180px) {
  .transfer-mid { padding: 16px 8px; }
  .transfer-mid .btn { width: 108px; padding: 0 8px; font-size: 13px; gap: 6px; }
}

/* ---------------------------------------------------------------- Handy-Layout */
@media (max-width: 900px), (max-height: 480px) and (pointer: coarse) {
  :root { --tabbar: 56px; }
  body { overflow: hidden; }
  .app { flex-direction: column; }
  .sidebar { display: none; }
  .main { flex: 1; min-height: 0; height: auto; }

  /* Obere Leiste: Statusleisten-Bereich beachten */
  .topbar { min-height: 52px; padding: calc(6px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 6px calc(16px + env(safe-area-inset-left)); flex-wrap: wrap; gap: 8px; }
  .topbar h2 { font-size: 20px; }
  [data-platform="ios"] .topbar { justify-content: center; position: relative; }
  [data-platform="ios"] .topbar h2 { position: absolute; left: 50%; transform: translateX(-50%); font-size: 17px; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  [data-platform="ios"] .topbar .spacer { display: none; }
  [data-platform="ios"] .topbar #themeBtn { margin-left: auto; }
  .context-banner { order: 5; width: 100%; justify-content: space-between; border-radius: 12px; }
  .view { padding: 16px calc(16px + env(safe-area-inset-right)) 16px calc(16px + env(safe-area-inset-left)); }
  .form-row, .radio-cards { grid-template-columns: 1fr; }
  .grid-cards { grid-template-columns: 1fr; }
  .page-head .btn { width: 100%; }
  .page-head > div:last-child { width: 100%; }
  .table td, .table th { padding: 10px 8px; }

  /* Untere Tab-Leiste */
  .tabbar { display: flex; flex: none; background: var(--surface); border-top: 1px solid var(--border); padding: 4px calc(6px + env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) calc(6px + env(safe-area-inset-left)); }
  [data-platform="ios"] .tabbar { background: color-mix(in srgb, var(--surface) 82%, transparent); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
  .tabbar button { flex: 1; min-width: 0; min-height: var(--tabbar); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 0; background: none; color: var(--muted); cursor: pointer; }
  .tabbar .tab-label { font-size: 11px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar svg.i { width: 24px; height: 24px; }
  .tabbar button.active { color: var(--accent); }
  /* Material 3: aktive Ansicht mit Pillen-Indikator */
  [data-platform="android"] .tabbar button { gap: 2px; }
  [data-platform="android"] .tabbar .tab-ico { width: 64px; height: 32px; border-radius: 16px; transition: background .2s; }
  [data-platform="android"] .tabbar button.active .tab-ico { background: var(--accent-soft); }
  [data-platform="android"] .tabbar button.active { color: var(--text); }
  [data-platform="android"] .tabbar button.active svg.i { color: var(--accent); }

  /* Dateiliste */
  .pane-head { padding: 10px 12px 8px; gap: 6px; }
  .pane-foot { padding: 6px 16px; }
  .selbar { position: sticky; top: 0; z-index: 3; padding: 4px 8px; gap: 2px; }
  .selbar .count { flex: 1; padding-left: 4px; }
  .panes:not(.dual) .pane-tools > :not(:last-child) { display: none; }

  /* Schwebender Aktionsknopf (Material FAB) */
  .fab { display: inline-flex; position: absolute; right: calc(16px + env(safe-area-inset-right)); bottom: 16px; z-index: 4; width: 56px; height: 56px; align-items: center; justify-content: center; border: 0; border-radius: 18px; background: var(--accent); color: var(--accent-text); box-shadow: 0 6px 18px rgba(20, 24, 40, .28); cursor: pointer; }
  .fab svg.i { width: 26px; height: 26px; }
  .fab:active { transform: scale(.96); }
  [data-platform="ios"] .fab { border-radius: 50%; }

  /* Übertragen: ein Fenster gleichzeitig, Umschalter oben (iOS Segmented Control) */
  .transfer-intro, .transfer-mid { display: none; }
  .seg { display: flex; flex: none; margin: 10px 16px; padding: 3px; border-radius: 10px; background: var(--surface-3); }
  .seg button { flex: 1; min-height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: none; font-weight: 600; font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
  .seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
  [data-platform="android"] .seg { border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
  [data-platform="android"] .seg button { border-radius: 999px; }
  [data-platform="android"] .seg button.active { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
  .panes.dual { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
  .panes.dual .pane { display: none; flex: 1; min-height: 0; border: 0; }
  .panes.dual.show-left .pane:first-child, .panes.dual.show-right .pane:last-child { display: flex; }
  .mbar { display: flex; flex: none; gap: 8px; padding: 10px 16px; background: var(--surface); border-top: 1px solid var(--border); }
  .mbar.hidden { display: none; }
  .mbar .btn { flex: 1; min-width: 0; height: auto; min-height: 48px; padding: 6px 10px; white-space: normal; line-height: 1.2; text-align: center; }
  .mbar .btn svg { display: none; }
  .mbar .btn.primary { flex: 1.3; }

  /* Dialoge werden zu Bottom Sheets */
  .modal-back { align-items: flex-end; padding: 0; }
  .modal, .modal.wide { max-width: none; width: 100%; max-height: 92dvh; border-radius: 20px 20px 0 0; border-bottom: 0; animation: sheet-up .26s cubic-bezier(.2, .8, .2, 1); }
  .modal::before { content: ""; display: block; width: 36px; height: 5px; margin: 8px auto 0; border-radius: 3px; background: var(--surface-3); }
  .modal-head { padding-top: 8px; }
  .modal-foot { flex-direction: column-reverse; gap: 8px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { width: 100%; height: 48px; }
  .modal.preview { height: 100dvh; max-height: none; border-radius: 0; }
  .modal.preview::before { display: none; }
  .modal.preview .modal-head { padding-top: calc(8px + env(safe-area-inset-top)); }
  .preview-body { min-height: 0; flex: 1; }
  .picker-list { height: 40dvh; }
  .picker-list button { height: 52px; }

  /* Aufgaben & Hinweise über der Tab-Leiste */
  .tasks { left: 8px; right: 8px; width: auto; max-width: none; bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom)); max-height: 40dvh; }
  .toasts { bottom: calc(var(--tabbar) + 24px + env(safe-area-inset-bottom)); }

  /* Anmeldeseite */
  .auth { padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); align-items: start; }
  .auth-card { margin-top: 6vh; padding: 24px; border-radius: 22px; }
}

/* Querformat am Handy: schmale Tab-Leiste */
@media (max-width: 920px) and (max-height: 480px) {
  :root { --tabbar: 44px; }
  .tabbar .tab-label { display: none; }
  .topbar { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}