:root {
  --bg: #0e1116;
  --bg-elevated: #171b23;
  --bg-card: #1c212b;
  --border: #2a313f;
  --text: #e8ebf0;
  --text-dim: #97a1b3;
  --accent: #4f8cff;
  --accent-hover: #6fa1ff;
  --danger: #e5484d;
  --danger-hover: #ff6369;
  --success: #3fb950;
  --radius: 10px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

button, input, select, textarea { font-family: inherit; font-size: 14px; }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s ease;
}
button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary { background: var(--bg-card); border: 1px solid var(--border); color: var(--text); }
button.secondary:hover { background: var(--bg-elevated); }
button.danger { background: var(--danger); }
button.danger:hover { background: var(--danger-hover); }
button.small { padding: 6px 12px; font-size: 13px; }

input[type="text"], input[type="password"], input[type="number"], textarea, select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); border-color: transparent; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 28px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.topbar .brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.topbar nav { display: flex; gap: 18px; align-items: center; font-size: 14px; }
.topbar nav .who { color: var(--text-dim); }

.container { max-width: 1100px; margin: 0 auto; padding: 32px 24px 64px; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p.sub { color: var(--text-dim); margin: 0 0 24px; font-size: 14px; }
.login-card label { display: block; margin: 14px 0 6px; font-size: 13px; color: var(--text-dim); }
.login-card .error {
  background: rgba(229, 72, 77, 0.12);
  border: 1px solid rgba(229, 72, 77, 0.4);
  color: #ff9297;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-top: 16px;
  display: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  margin-top: 24px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); }
.card .thumb {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 13px;
  overflow: hidden;
}
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .body { padding: 14px 16px; }
.card .body h3 { margin: 0 0 4px; font-size: 15px; }
.card .body p { margin: 0; color: var(--text-dim); font-size: 13px; line-height: 1.4; }

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 80px 20px;
  font-size: 14px;
}

/* Viewer – Vollflächig, Bedienelemente als Overlay */
body.viewer-page { background: #000; overflow: hidden; overscroll-behavior: none; }
.viewer-wrap {
  position: fixed; inset: 0; height: 100vh; height: 100dvh;
  background: #000; overflow: hidden;
}
#psv-container {
  position: absolute; top: 0; left: 0; right: 0;
  bottom: env(safe-area-inset-bottom, 0px);
}
.vw-ui { transition: opacity 0.3s ease; }
.viewer-wrap.idle .vw-ui { opacity: 0; pointer-events: none; }

.vw-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) calc(10px + env(safe-area-inset-right, 0px)) 18px calc(10px + env(safe-area-inset-left, 0px));
  background: linear-gradient(rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0));
  pointer-events: none;
}
.vw-top > * { pointer-events: auto; }
.vw-title {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.vw-title #projectTitle { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vw-sub { font-size: 12px; color: rgba(255, 255, 255, 0.8); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.vw-btn, .vw-arrow {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 40px; height: 40px; padding: 0; border: none; border-radius: 50%;
  background: rgba(0, 0, 0, 0.45); color: #fff; cursor: pointer;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.vw-btn:hover, .vw-arrow:hover { background: rgba(0, 0, 0, 0.7); color: #fff; }
.vw-btn svg { width: 20px; height: 20px; }
.vw-btn[hidden], .vw-arrow[hidden], .vw-strip[hidden] { display: none; }

.vw-arrow { position: absolute; top: 50%; transform: translateY(-50%); z-index: 20; width: 44px; height: 44px; }
.vw-arrow svg { width: 24px; height: 24px; }
.vw-prev { left: calc(10px + env(safe-area-inset-left, 0px)); }
.vw-next { right: calc(10px + env(safe-area-inset-right, 0px)); }

.vw-strip {
  position: absolute; left: 0; right: 0; z-index: 25;
  bottom: calc(48px + env(safe-area-inset-bottom, 0px));
  display: flex; gap: 8px; overflow-x: auto; padding: 10px;
  background: rgba(0, 0, 0, 0.72);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.vw-thumb {
  flex: 0 0 auto; width: 124px; padding: 0; text-align: left; cursor: pointer;
  border: 2px solid transparent; border-radius: 8px; overflow: hidden;
  background: #1c212b; color: #fff;
}
.vw-thumb:hover { background: #262c38; border-color: rgba(255, 255, 255, 0.3); }
.vw-thumb.active { border-color: var(--accent); }
.vw-thumb img, .vw-thumb .ph { display: block; width: 120px; height: 60px; object-fit: cover; }
.vw-thumb .ph { display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--text-dim); }
.vw-thumb .t { display: block; font-size: 11px; font-weight: 400; padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Admin */
.tabs { display: flex; gap: 6px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.tabs button {
  background: transparent; color: var(--text-dim); border-radius: 0; padding: 10px 16px;
  border-bottom: 2px solid transparent;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); background: transparent; }
.tabs button:hover { background: var(--bg-card); color: var(--text); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; font-size: 12px; text-transform: uppercase; }
tr:hover td { background: rgba(255,255,255,0.02); }

.panel {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 24px;
}
.panel h2 { margin: 0 0 16px; font-size: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.field { flex: 1; min-width: 160px; }
.field label { display: block; margin-bottom: 6px; font-size: 12px; color: var(--text-dim); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.pill.admin { background: rgba(79,140,255,0.15); color: #7fb0ff; }
.pill.user { background: rgba(255,255,255,0.08); color: var(--text-dim); }
.pill.inactive { background: rgba(229,72,77,0.15); color: #ff9297; }

.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: 8px; padding: 12px 18px; font-size: 13px;
  box-shadow: var(--shadow); z-index: 100; max-width: 320px;
}
.toast.error { border-color: var(--danger); color: #ff9297; }
.toast.ok { border-color: var(--success); color: #a4e8ac; }

.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--bg-elevated); border-radius: 8px; }
.checkbox-row input { width: auto; }

.muted { color: var(--text-dim); }
.mt-16 { margin-top: 16px; }
