:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1f2733;
  --muted: #6b7686;
  --line: #e3e8ef;
  --primary: #2563eb;
  --primary-ink: #ffffff;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.06);
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

a { color: var(--primary); }

.container { max-width: 1200px; margin: 0 auto; padding: 20px; }
.narrow { max-width: 460px; }

/* ---- Kopfzeile ---- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.topbar .inner {
  max-width: 1200px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 16px;
}
.topbar .brand { font-weight: 700; font-size: 1.1rem; }
.topbar .brand .sub { color: var(--muted); font-weight: 400; font-size: .85rem; }
.topbar nav { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---- Karten ---- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card h2 { margin-top: 0; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line);
  background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 9px;
  font-size: .95rem; cursor: pointer; text-decoration: none;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #f6f8fb; }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: #f3c6c6; }
.btn-danger:hover { background: #fdeaea; }
.btn-sm { padding: 5px 10px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Formulare ---- */
label { display: block; font-weight: 600; margin: 12px 0 4px; font-size: .9rem; }
input[type=text], input[type=password], input[type=search], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 9px; font-size: 1rem; background: #fff; color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 2px solid #bfd3ff; border-color: var(--primary); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > * { margin: 0; }

/* ---- Meldungen ---- */
.alert { padding: 12px 14px; border-radius: 9px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-ok    { background: #e9f9ef; color: #14532d; border-color: #bbf0cc; }
.alert-err   { background: #fdeaea; color: #7f1d1d; border-color: #f3c6c6; }
.alert-info  { background: #eaf1fe; color: #1e3a8a; border-color: #c7d9fb; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---- Tabellen ---- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tr:hover td { background: #fafbfd; }

/* ---- Breadcrumb ---- */
.crumbs { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.crumbs a { text-decoration: none; }
.crumbs .sep { color: var(--muted); }

/* ---- Kopier-Feld ---- */
.copyfield { display: flex; gap: 8px; align-items: stretch; }
.copyfield input { font-family: ui-monospace, Menlo, Consolas, monospace; }

/* ---- Datei-/Ordner-Grid ---- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }

.folders { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.folder-chip {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  padding: 10px 14px; text-decoration: none; color: var(--ink);
}
.folder-chip:hover { background: #f6f8fb; }
.folder-chip .ico { font-size: 1.3rem; }
.folder-chip .cnt { color: var(--muted); font-size: .8rem; }

/* Grid der Dateien */
.grid { display: grid; gap: 12px; }
.view-small  { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.view-large  { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.view-xlarge { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.view-list   { grid-template-columns: 1fr; }

.tile {
  position: relative; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; overflow: hidden; display: flex; flex-direction: column;
}
.tile.selected { outline: 3px solid var(--primary); border-color: var(--primary); }
.tile .thumb {
  aspect-ratio: 1 / 1; background: #f0f2f6 center/cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.6rem; color: var(--muted); cursor: zoom-in;
}
.tile .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .meta { padding: 8px 10px; font-size: .82rem; }
.tile .meta .fn { font-weight: 600; word-break: break-word; }
.tile .meta .fs { color: var(--muted); }
.tile .pick {
  position: absolute; top: 8px; left: 8px; width: 22px; height: 22px;
  z-index: 2; accent-color: var(--primary); cursor: pointer;
}
.tile .actions { display: flex; gap: 6px; padding: 0 10px 10px; flex-wrap: wrap; }

/* Listenansicht */
.view-list .tile { flex-direction: row; align-items: center; }
.view-list .tile .thumb { width: 56px; aspect-ratio: 1/1; font-size: 1.5rem; flex: none; }
.view-list .tile .meta { flex: 1; }
.view-list .tile .pick { position: static; margin: 0 10px; }
.view-list .tile .actions { padding: 10px; }

/* ---- Sticky Auswahl-Leiste ---- */
.selbar {
  position: sticky; bottom: 0; z-index: 20;
  background: var(--card); border-top: 1px solid var(--line);
  box-shadow: 0 -2px 8px rgba(16,24,40,.06);
  padding: 12px 20px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.selbar .count { font-weight: 600; }

/* ---- Lightbox ---- */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.85);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 24px;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.lightbox .close {
  position: absolute; top: 16px; right: 20px; color: #fff; font-size: 2rem;
  cursor: pointer; background: none; border: none;
}

/* ---- Login ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; }
.login-card h1 { font-size: 1.4rem; margin: 0 0 4px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; background: #eef2f7; color: var(--muted); }
.badge-ok { background: #e9f9ef; color: #14532d; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-err { background: #fdeaea; color: #7f1d1d; }

@media (max-width: 600px) {
  .container { padding: 14px; }
  .topbar .inner { padding: 10px 14px; }
}
