:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --danger: #ef4444;
  --success: #22c55e;
  --fav: #f43f5e;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: var(--text); background: var(--bg); font-size: 15px; }

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

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem; border-radius: 7px; border: none; cursor: pointer;
  font-size: .875rem; font-weight: 500; transition: background .15s, opacity .15s;
  text-decoration: none;
}
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; text-decoration: none; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .85; }
.btn-ghost    { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--border); color: var(--text); text-decoration: none; }
.btn-outline  { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--border); text-decoration: none; }
.btn-sm       { padding: .35rem .75rem; font-size: .8rem; }
.btn-link     { background: none; border: none; color: var(--primary); cursor: pointer; font-size: inherit; padding: 0; }

/* ── Nav ── */
.topnav {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.topnav-brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.1rem; color: var(--text); }
.topnav-right { display: flex; align-items: center; gap: .75rem; }
.avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }

/* ── Layout ── */
.container { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }
.container-sm { max-width: 600px; }

/* ── Login ── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #667eea22 0%, #764ba222 100%); }
.login-card { background: var(--surface); border-radius: 16px; padding: 2.5rem; width: 100%; max-width: 400px; box-shadow: var(--shadow-md); text-align: center; }
.login-logo { display: flex; align-items: center; justify-content: center; gap: .6rem; font-size: 1.4rem; font-weight: 800; margin-bottom: 1.5rem; color: var(--text); }
.login-card h1 { font-size: 1.5rem; margin-bottom: .4rem; }
.login-sub { color: var(--muted); margin-bottom: 1.5rem; }
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  width: 100%; padding: .7rem 1rem; border: 1.5px solid var(--border); border-radius: 8px;
  background: var(--surface); font-weight: 500; color: var(--text); cursor: pointer; transition: background .15s;
  text-decoration: none;
}
.btn-google:hover { background: var(--bg); text-decoration: none; }

/* ── Alerts ── */
.alert-error   { background: #fee2e2; color: #991b1b; border-radius: 8px; padding: .75rem 1rem; margin-bottom: 1rem; }
.alert-success { background: #dcfce7; color: #166534; border-radius: 8px; padding: .75rem 1rem; margin-bottom: 1rem; }

/* ── Page Header ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.5rem; }

/* ── Gallery Cards (Dashboard) ── */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.gallery-card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; transition: box-shadow .2s; }
.gallery-card:hover { box-shadow: var(--shadow-md); }
.gallery-card-inner { display: block; text-decoration: none; color: inherit; }
.gallery-card-cover { aspect-ratio: 4/3; background: var(--bg); overflow: hidden; }
.gallery-card-cover img { width: 100%; height: 100%; object-fit: cover; }
.gallery-card-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.gallery-card-info { padding: .85rem; }
.gallery-card-info strong { display: block; font-size: .95rem; margin-bottom: .2rem; }
.gallery-card-stats { display: flex; gap: .75rem; margin-top: .4rem; font-size: .8rem; color: var(--muted); }
.fav-badge { color: var(--fav); }
.meta { color: var(--muted); font-size: .85rem; }

/* ── Empty State ── */
.empty-state { text-align: center; padding: 4rem 1rem; display: flex; flex-direction: column; align-items: center; gap: 1rem; color: var(--muted); }

/* ── Link Box ── */
.link-box { display: flex; align-items: center; gap: .6rem; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: .6rem .85rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.link-label { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.link-input { flex: 1; border: none; background: transparent; font-size: .85rem; color: var(--text); min-width: 0; outline: none; font-family: monospace; }

/* ── Upload Zone ── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 2.5rem 1rem;
  text-align: center; cursor: pointer; transition: border-color .2s, background .2s;
  margin-bottom: 1rem;
}
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--primary); background: #6366f108; }
.upload-zone svg { color: var(--muted); margin-bottom: .75rem; }
.upload-zone p { color: var(--muted); }
.upload-progress { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.progress-bar { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width .2s; width: 0; }

/* ── Photo Grid (Admin) ── */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .75rem; margin-top: 1.5rem; }
.photo-item { background: var(--surface); border-radius: 8px; border: 1px solid var(--border); overflow: hidden; }
.photo-thumb { aspect-ratio: 4/3; overflow: hidden; position: relative; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.fav-indicator { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.55); color: var(--fav); padding: 2px 7px; border-radius: 20px; font-size: .75rem; }
.photo-actions { display: flex; align-items: center; padding: .4rem .5rem; gap: .4rem; }
.photo-name { flex: 1; font-size: .75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-icon { background: none; border: none; cursor: pointer; padding: 3px 6px; border-radius: 4px; color: var(--muted); }
.btn-delete:hover { background: #fee2e2; color: var(--danger); }

/* ── Form ── */
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .35rem; }
.form-control { width: 100%; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: 6px; font-size: .9rem; color: var(--text); background: var(--surface); outline: none; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px #6366f120; }
textarea.form-control { resize: vertical; }
.form-check label { display: flex; align-items: center; gap: .5rem; font-weight: normal; cursor: pointer; }
.form-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.25rem; }

/* ── Settings Panel ── */
.settings-panel { margin-top: 2rem; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.settings-panel summary { padding: .85rem 1rem; cursor: pointer; font-weight: 500; background: var(--bg); }
.settings-panel[open] summary { border-bottom: 1px solid var(--border); }
.settings-panel .form-card { border: none; border-radius: 0; }

/* ── Gallery Header (Admin) ── */
.gallery-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.25rem; }

/* ══════════════════════════════════════
   VIEWER (Client-Ansicht)
══════════════════════════════════════ */
.viewer-body { background: #0f172a; color: #e2e8f0; min-height: 100vh; }

.viewer-header {
  padding: 1.5rem 2rem; border-bottom: 1px solid #1e293b;
}
.viewer-header-inner { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.viewer-title { font-size: 1.5rem; font-weight: 700; color: #f1f5f9; }
.viewer-sub   { color: #94a3b8; margin-top: .2rem; }
.viewer-desc  { color: #94a3b8; margin-top: .75rem; font-size: .9rem; }
.viewer-actions { display: flex; gap: .6rem; flex-wrap: wrap; padding-top: .2rem; }
.viewer-body .btn-outline { border-color: #334155; color: #94a3b8; }
.viewer-body .btn-outline:hover { background: #1e293b; color: #e2e8f0; }

.viewer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 3px;
  padding: 3px;
}
.viewer-item { position: relative; background: #1e293b; overflow: hidden; border-radius: 3px; }
.viewer-thumb { aspect-ratio: 3/2; overflow: hidden; cursor: pointer; }
.viewer-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.viewer-item:hover .viewer-thumb img { transform: scale(1.04); }

.viewer-item-actions {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: .4rem .5rem;
  background: linear-gradient(to top, rgba(0,0,0,.7), transparent);
  opacity: 0; transition: opacity .2s;
}
.viewer-item:hover .viewer-item-actions { opacity: 1; }

.btn-fav {
  background: none; border: none; cursor: pointer;
  color: #94a3b8; display: flex; align-items: center; gap: .3rem;
  padding: 4px 8px; border-radius: 6px; transition: color .15s, background .15s;
  font-size: .8rem;
}
.btn-fav:hover { background: rgba(255,255,255,.1); }
.btn-fav.active { color: var(--fav); }
.btn-fav.active svg path { fill: var(--fav); }

.btn-dl {
  background: rgba(255,255,255,.15); border: none; cursor: pointer;
  color: #e2e8f0; padding: 4px 8px; border-radius: 6px;
  display: flex; align-items: center; transition: background .15s;
}
.btn-dl:hover { background: rgba(255,255,255,.25); }

/* ── Lightbox ── */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.95);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
}
.lb-content { position: relative; max-width: 90vw; max-height: 90vh; display: flex; flex-direction: column; align-items: center; }
.lb-content img { max-width: 90vw; max-height: 80vh; object-fit: contain; border-radius: 4px; }
.lb-footer { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: .75rem 0; }
.lb-footer .lb-actions { display: flex; gap: .6rem; }
#lbCounter { color: #94a3b8; font-size: .85rem; }
.lb-close, .lb-prev, .lb-next {
  position: fixed; background: rgba(255,255,255,.1); border: none; color: #fff;
  cursor: pointer; border-radius: 50%; width: 44px; height: 44px;
  font-size: 1.1rem; display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.lb-close:hover, .lb-prev:hover, .lb-next:hover { background: rgba(255,255,255,.2); }
.lb-close { top: 1.2rem; right: 1.2rem; }
.lb-prev  { left: 1rem; top: 50%; transform: translateY(-50%); }
.lb-next  { right: 1rem; top: 50%; transform: translateY(-50%); }
.lb-fav { color: #94a3b8; }
.lb-fav.active { color: var(--fav); }
.viewer-body .btn-outline { font-size: .8rem; }

/* ── Dateityp-Badges ── */
.file-type-badge {
  position: absolute; bottom: 6px; left: 6px;
  font-size: .65rem; font-weight: 700; padding: 2px 6px; border-radius: 4px; letter-spacing: .04em;
}
.badge-image    { background: #1e293b; color: #94a3b8; display: none; }
.badge-video    { background: #7c3aed; color: #fff; }
.badge-audio    { background: #0891b2; color: #fff; }
.badge-document { background: #d97706; color: #fff; }

/* ── Media-Thumb-Placeholder ── */
.media-thumb-placeholder {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: .4rem;
}
.type-video    { background: #1e1b4b; }
.type-audio    { background: #0c1a1f; }
.type-document { background: #1c1410; }
.file-icon     { width: 36px; height: 36px; }
.file-icon-video    { color: #818cf8; }
.file-icon-audio    { color: #22d3ee; }
.file-icon-pdf      { color: #fb923c; }
.file-icon-doc      { color: #fbbf24; }
.media-type-label   { font-size: .75rem; color: #94a3b8; }
.play-overlay       { position: absolute; }

/* ── Viewer-Dateiname ── */
.viewer-filename {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(to top, rgba(0,0,0,.8), transparent);
  padding: .5rem .4rem .3rem; font-size: .7rem; color: #cbd5e1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transition: opacity .2s;
}
.viewer-item:hover .viewer-filename { opacity: 1; }

/* ── Video/Audio/PDF Modal ── */
.media-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.95);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
}
.media-modal-inner { display: flex; flex-direction: column; align-items: center; max-width: 90vw; }
.audio-player-card {
  background: #1e293b; border-radius: 16px; padding: 2.5rem 2rem;
  display: flex; flex-direction: column; align-items: center; min-width: 320px;
}

/* ── Ordner-Tabs (Admin) ── */
.folder-bar { margin-bottom: 1rem; }
.folder-tabs { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }
.folder-tab {
  background: var(--bg); border: 1px solid var(--border); border-radius: 20px;
  padding: .3rem .85rem; font-size: .82rem; cursor: pointer; transition: background .15s;
  display: flex; align-items: center; gap: .4rem; white-space: nowrap;
}
.folder-tab:hover { background: var(--border); }
.folder-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.folder-tab-add { border-style: dashed; color: var(--primary); }
.folder-count { font-size: .75rem; opacity: .7; }
.folder-tab-actions { display: none; gap: .2rem; }
.folder-tab:hover .folder-tab-actions { display: flex; }
.folder-tab-actions span { padding: 0 3px; opacity: .6; }
.folder-tab-actions span:hover { opacity: 1; }

.add-folder-form { display: flex; gap: .5rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.add-folder-form.hidden { display: none; }
.upload-section { margin-bottom: 1.5rem; }
.upload-folder-select { margin-bottom: .6rem; display: flex; align-items: center; gap: .6rem; font-size: .85rem; }

/* ── Nutzertabelle ── */
.user-table { display: flex; flex-direction: column; gap: .5rem; }
.user-row { display: flex; align-items: center; gap: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; flex-wrap: wrap; }
.user-row-pending { border-color: #fbbf24; background: #fffbeb; }
.user-info { display: flex; align-items: center; gap: .75rem; flex: 1; min-width: 200px; }
.user-meta { display: flex; align-items: center; gap: .75rem; flex-shrink: 0; }
.user-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.avatar-placeholder { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; }
.role-badge { font-size: .75rem; padding: 2px 8px; border-radius: 10px; font-weight: 500; }
.role-platform_admin { background: #dbeafe; color: #1e40af; }
.role-photographer   { background: #dcfce7; color: #166534; }
.role-pending        { background: #fef3c7; color: #92400e; }
.badge { font-size: .7rem; padding: 1px 6px; border-radius: 8px; vertical-align: middle; }
.badge-you { background: #e0e7ff; color: #3730a3; }
.badge-pending { background: #fbbf24; color: #fff; padding: 2px 8px; border-radius: 12px; font-size: .8rem; font-weight: 600; }
.badge-pending-sm { background: #ef4444; color: #fff; border-radius: 50%; width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; font-size: .7rem; font-weight: 700; }

/* ── Ordner-Tabs (Viewer) ── */
.viewer-folder-bar {
  display: flex; gap: .4rem; flex-wrap: wrap; padding: .85rem 2rem;
  border-bottom: 1px solid #1e293b; background: #0f172a; position: sticky; top: 0; z-index: 10;
}
.viewer-folder-tab {
  background: transparent; border: 1px solid #334155; border-radius: 20px;
  padding: .3rem .85rem; font-size: .82rem; cursor: pointer; color: #94a3b8;
  transition: all .15s; white-space: nowrap;
}
.viewer-folder-tab:hover  { background: #1e293b; color: #e2e8f0; }
.viewer-folder-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.viewer-folder-tab .folder-count { opacity: .6; }

/* ── Preis-Badges & Chips ── */
.price-badge { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.7); color: #fbbf24; font-size: .65rem; font-weight: 700; padding: 2px 6px; border-radius: 4px; }
.price-badge-tab { background: #fbbf24; color: #000; font-size: .65rem; font-weight: 700; padding: 1px 5px; border-radius: 4px; }
.price-chip { background: #fef3c7; color: #92400e; font-size: .8rem; padding: 3px 10px; border-radius: 12px; font-weight: 600; }
.price-chip-free { background: #dcfce7; color: #166534; }
.price-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.token-price { font-size: 1rem; font-weight: 700; color: #fbbf24; }

/* ── Shop ── */
.email-login-banner { background: #1e293b; border-bottom: 1px solid #334155; padding: 1rem 2rem; display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.email-login-banner p { color: #94a3b8; }
.wallet-chip { display: flex; align-items: center; gap: .4rem; background: #1e293b; border: 1px solid #334155; padding: .3rem .85rem; border-radius: 20px; color: #e2e8f0; font-size: .85rem; font-weight: 600; }

.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.shop-item { background: #1e293b; border-radius: 10px; overflow: hidden; border: 1px solid #334155; }
.shop-item-owned { border-color: #22c55e40; }
.shop-thumb { aspect-ratio: 4/3; position: relative; overflow: hidden; background: #0f172a; }
.shop-thumb img { width: 100%; height: 100%; object-fit: cover; }
.shop-lock-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; }
.shop-owned-badge { position: absolute; top: 8px; right: 8px; background: #22c55e; color: #fff; font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 10px; }
.shop-item-info { padding: .85rem; display: flex; flex-direction: column; gap: .3rem; }
.shop-price { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-top: .4rem; }

.packages-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1.5rem; }
.package-card { background: #1e293b; border: 1px solid #334155; border-radius: 10px; padding: 1.25rem; text-align: center; display: flex; flex-direction: column; gap: .5rem; align-items: center; }
.package-tokens { font-size: 1.5rem; font-weight: 800; color: #fbbf24; }
.package-price { color: #94a3b8; font-size: .9rem; }
.payment-info-box { background: #1e293b; border: 1px solid #334155; border-radius: 10px; padding: 1.25rem; color: #e2e8f0; margin-top: 1rem; }
.payment-info-box h3 { font-size: 1rem; margin-bottom: .75rem; color: #22c55e; }

/* ── Viewer Lock-Overlay ── */
.viewer-item-locked .viewer-thumb { position: relative; }
.viewer-item-locked .viewer-item-actions { display: none !important; }
.viewer-lock-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: .4rem; cursor: pointer;
  background: rgba(15,23,42,.15); border-radius: inherit;
  transition: background .2s;
}
.viewer-lock-overlay:hover { background: rgba(15,23,42,.3); }
.viewer-lock-overlay svg { color: #fbbf24; }
.viewer-lock-price {
  font-size: .8rem; font-weight: 700; color: #fbbf24;
  background: rgba(0,0,0,.65); padding: 2px 8px; border-radius: 10px;
}

/* ── Wallet-Bar ── */
.wallet-bar {
  background: #1e293b; border: 1px solid #334155; border-radius: 10px;
  padding: .75rem 1rem; margin: 0 1rem 1rem; display: flex; align-items: center;
  gap: .75rem; flex-wrap: wrap; font-size: .9rem;
}

/* ── Viewer Toolbar (sort + folders) ── */
.viewer-toolbar {
  display: flex; align-items: flex-start; flex-wrap: wrap; gap: .5rem;
  padding: .5rem 1rem; position: sticky; top: 0; z-index: 10;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.sort-controls { margin-left: auto; }
.sort-select {
  background: #1e293b; border: 1px solid #334155; color: #e2e8f0;
  border-radius: 8px; padding: .35rem .6rem; font-size: .85rem; cursor: pointer;
}

/* ── Mobile Upload Buttons ── */
.upload-btn-row { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; margin: .75rem 0 .4rem; }
.upload-btn-main { min-width: 160px; }
.upload-btn-camera { display: flex; align-items: center; gap: .4rem; }
.upload-hint { font-size: .82rem; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .container { padding: 1rem; }
  .topnav { padding: .6rem 1rem; }
  .viewer-header { padding: 1rem; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .viewer-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .link-box { flex-direction: column; align-items: stretch; }
}
