:root {
  --bg: #08070a;
  --bg-alt: #0e0c11;
  --surface: rgba(255,255,255,0.045);
  --surface-strong: rgba(255,255,255,0.08);
  --border: rgba(255,255,255,0.09);
  --border-strong: rgba(255,255,255,0.16);
  --text: #f2eee8;
  --text-dim: #a79f9a;
  --text-faint: #6f6863;
  --accent: #ff4d2e;
  --accent-2: #ff8a3d;
  --accent-soft: rgba(255,77,46,0.16);
  --danger: #ff5470;
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 9px;
  --shadow-glow: 0 0 40px rgba(255,77,46,0.18);
  color-scheme: dark;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { max-width: 100%; }
[hidden] { display: none !important; }
button { font-family: inherit; }

/* ---------- Ambient background ---------- */

.grain {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.spotlights {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.spot {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  animation: drift 26s ease-in-out infinite alternate;
}
.spot-a { width: 46vw; height: 46vw; left: -10vw; top: -14vw; background: radial-gradient(circle, var(--accent), transparent 70%); }
.spot-b { width: 38vw; height: 38vw; right: -8vw; top: 10vh; background: radial-gradient(circle, var(--accent-2), transparent 70%); animation-delay: -8s; }
.spot-c { width: 50vw; height: 50vw; left: 20vw; bottom: -22vw; background: radial-gradient(circle, #7a2bff, transparent 70%); opacity: 0.18; animation-delay: -16s; }

@keyframes drift {
  from { transform: translate(0,0) scale(1); }
  to { transform: translate(4%, 6%) scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  .spot { animation: none; }
}

/* ---------- Layout ---------- */

.topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  backdrop-filter: blur(16px);
  background: rgba(8,7,10,0.55);
  border-bottom: 1px solid var(--border);
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s, border-color .2s, transform .15s;
}
.back-btn:hover { background: var(--surface-strong); border-color: var(--border-strong); }
.back-btn:active { transform: scale(0.96); }
.back-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark {
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 15px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sub { font-size: 12px; color: var(--text-faint); letter-spacing: 0.04em; }
.topbar-spacer { flex: 1; }

main#app {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 8px 20px 140px;
}

.view {
  animation: fadeUp .5s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Hero / Dashboard ---------- */

.hero { text-align: center; padding: 48px 0 36px; }
.hero-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.35em;
  font-size: 11px;
  color: var(--accent-2);
  margin: 0 0 14px;
}
.hero-title {
  font-size: clamp(42px, 11vw, 84px);
  line-height: 0.95;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
  background: linear-gradient(180deg, #fff, #c9c2bc 60%, #857c76);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 60px rgba(255,120,70,0.15);
}
.hero-tagline {
  margin: 18px 0 0;
  color: var(--text-dim);
  font-size: 15px;
  letter-spacing: 0.02em;
}

.vault-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 12px;
}
@media (max-width: 640px) {
  .vault-cards { grid-template-columns: 1fr; }
}

.vault-card {
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: 40px 24px 30px;
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, rgba(255,255,255,0.06), rgba(255,255,255,0.015));
  border: 1px solid var(--border);
  backdrop-filter: blur(14px);
  cursor: pointer;
  color: var(--text);
  transition: transform .3s cubic-bezier(.2,.8,.2,1), border-color .3s, box-shadow .3s;
  animation: fadeUp .6s cubic-bezier(.2,.8,.2,1) both;
}
.vault-card:nth-child(2) { animation-delay: .08s; }
.vault-card:hover {
  transform: translateY(-6px);
  border-color: rgba(255,120,70,0.4);
  box-shadow: var(--shadow-glow);
}
.vault-card:active { transform: translateY(-2px) scale(0.99); }

.vault-card-glow {
  position: absolute;
  inset: -40% -40% auto -40%;
  height: 60%;
  background: radial-gradient(circle, var(--accent-soft), transparent 70%);
  opacity: 0;
  transition: opacity .4s;
}
.vault-card:hover .vault-card-glow { opacity: 1; }

.vault-card-icon { font-size: 34px; margin-bottom: 10px; }
.vault-card h2 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0.06em;
  font-weight: 800;
}
.vault-card-sub { color: var(--text-dim); margin: 6px 0 18px; font-size: 14px; }
.vault-card-stats {
  display: inline-block;
  font-size: 13px;
  color: var(--text-faint);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 22px;
}
.vault-card-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
}
.vault-card-cta svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .25s; }
.vault-card:hover .vault-card-cta svg { transform: translateX(4px); }

.all-files-link {
  display: block;
  margin: 26px auto 0;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  padding: 8px;
  transition: color .2s;
}
.all-files-link:hover { color: var(--accent-2); }

.activity { margin-top: 56px; }
.activity h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-faint);
  margin: 0 0 14px;
}
.activity-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.activity-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  animation: fadeUp .4s cubic-bezier(.2,.8,.2,1) both;
}
.activity-list .activity-empty { color: var(--text-faint); justify-content: center; }
.activity-icon { font-size: 16px; }
.activity-text { flex: 1; color: var(--text); }
.activity-text b { color: var(--accent-2); font-weight: 600; }
.activity-time { color: var(--text-faint); font-size: 12px; white-space: nowrap; }

/* ---------- Vault / gallery ---------- */

.vault-header { display: flex; align-items: center; justify-content: space-between; padding: 26px 0 20px; gap: 12px; flex-wrap: wrap; }
.vault-header-title { display: flex; align-items: center; gap: 14px; }
.vault-header-icon {
  font-size: 26px;
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}
.vault-header-title h2 { margin: 0; font-size: 22px; letter-spacing: 0.03em; }
.vault-header-sub { margin: 2px 0 0; color: var(--text-faint); font-size: 13px; }

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 34px 20px;
  text-align: center;
  background: var(--surface);
  transition: border-color .25s, background .25s, transform .2s;
  margin-bottom: 22px;
}
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(1.01);
}
.dropzone-icon {
  width: 52px; height: 52px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 30px rgba(255,90,40,0.35);
}
.dropzone-text { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.dropzone-or { color: var(--text-faint); font-size: 12px; margin: 0 0 14px; text-transform: uppercase; letter-spacing: 0.1em; }
.dropzone-hint { color: var(--text-faint); font-size: 12px; margin: 14px 0 0; letter-spacing: 0.03em; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform .15s, box-shadow .25s, background .2s, border-color .2s;
  min-height: 44px;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #170a06;
  box-shadow: 0 6px 24px rgba(255,90,40,0.28);
}
.btn-primary:hover { box-shadow: 0 8px 30px rgba(255,90,40,0.42); }
.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:hover { background: var(--surface-strong); border-color: var(--border-strong); }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.filter-group { display: flex; gap: 8px; }
.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: all .2s;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.active {
  background: var(--accent-soft);
  border-color: rgba(255,120,70,0.5);
  color: var(--accent-2);
}
.toolbar-right { display: flex; align-items: center; gap: 10px; }
.select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}
.view-toggle { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.icon-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: none;
  border-radius: 999px;
  color: var(--text-faint);
  cursor: pointer;
  transition: all .2s;
}
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.icon-btn:hover { color: var(--text); }
.icon-btn.active { background: var(--accent-soft); color: var(--accent-2); }

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

/* ---------- File grid ---------- */

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
}
.file-grid.list-mode { grid-template-columns: 1fr; }

.file-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform .25s cubic-bezier(.2,.8,.2,1), border-color .25s, box-shadow .25s;
  animation: cardIn .4s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.file-card:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: 0 12px 30px rgba(0,0,0,0.4); }

.file-thumb {
  aspect-ratio: 1 / 1;
  background: #150f10 center/cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px;
  color: var(--text-faint);
  position: relative;
}
.file-thumb .play-badge {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, transparent 50%, rgba(0,0,0,0.55));
}
.file-thumb .play-badge svg {
  width: 40px; height: 40px;
  fill: rgba(255,255,255,0.92);
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
}
.file-owner-badge {
  position: absolute; top: 8px; left: 8px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.12);
}
.file-info { padding: 10px 12px 12px; }
.file-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0 0 4px;
}
.file-meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.file-meta span { font-size: 11.5px; color: var(--text-faint); }
.file-actions { display: flex; gap: 6px; margin-top: 10px; }
.file-actions .icon-btn {
  background: var(--surface); border: 1px solid var(--border);
  width: auto; flex: 1; min-width: 0;
  padding: 0 8px; height: 32px; border-radius: 8px;
  font-size: 12px; gap: 5px; color: var(--text-dim);
  overflow: hidden; white-space: nowrap;
}
.file-actions .icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.file-actions .btn-label { overflow: hidden; text-overflow: ellipsis; }

/* Grid-Karten sind zu schmal fuer Text+Icon nebeneinander -> nur Icons.
   In der Listenansicht ist genug Platz fuer die vollen Labels. */
.file-grid:not(.list-mode) .file-actions .btn-label { display: none; }
.file-grid:not(.list-mode) .file-actions .icon-btn { flex: 0 0 32px; font-size: 15px; }

/* list mode */
.file-grid.list-mode .file-card { display: flex; align-items: center; }
.file-grid.list-mode .file-thumb { width: 74px; height: 74px; aspect-ratio: auto; flex-shrink: 0; font-size: 22px; }
.file-grid.list-mode .file-info { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; }
.file-grid.list-mode .file-name { max-width: 260px; }
.file-grid.list-mode .file-actions { margin-top: 0; }

/* ---------- Upload panel ---------- */

.upload-panel {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  width: min(380px, calc(100vw - 40px));
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  background: rgba(14,12,17,0.85);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  z-index: 40;
  animation: slideIn .35s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.upload-panel-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}
.upload-overall { flex: 1; display: flex; flex-direction: column; gap: 5px; }
#uploadOverallLabel { font-size: 11px; color: var(--text-faint); font-weight: 500; }
.upload-list { overflow-y: auto; padding: 8px 14px 14px; display: flex; flex-direction: column; gap: 12px; }

.upload-item { font-size: 12.5px; }
.upload-item-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.upload-item-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 210px; }
.upload-item-pct { color: var(--text-faint); }
.progress-track {
  height: 7px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  width: 0%;
  transition: width .25s ease-out;
}
.upload-item-sub { display: flex; justify-content: space-between; margin-top: 5px; font-size: 11px; color: var(--text-faint); }
.upload-item.queued .progress-fill { background: rgba(255,255,255,0.18); }
.upload-item.error .progress-fill { background: var(--danger); }
.upload-item.done .progress-fill { background: #37d67a; }
.upload-item.error .upload-item-sub { color: var(--danger); }

/* ---------- Modals ---------- */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(4,3,5,0.82);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 60;
  padding: 20px;
  animation: fadeIn .25s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: #0e0c11;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  animation: modalIn .3s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.94) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.preview-modal { width: min(920px, 100%); overflow: hidden; position: relative; }
.modal-close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.modal-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.preview-body {
  background: #000;
  display: flex; align-items: center; justify-content: center;
  max-height: 72vh;
  min-height: 200px;
}
.preview-body video, .preview-body img { max-width: 100%; max-height: 72vh; display: block; }
.preview-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px;
  flex-wrap: wrap;
}
.preview-name { margin: 0; font-weight: 600; font-size: 14px; }
.preview-sub { margin: 4px 0 0; font-size: 12px; color: var(--text-faint); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: rgba(20,16,18,0.95);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 80;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  animation: toastIn .3s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Mobile ---------- */

@media (max-width: 560px) {
  main#app { padding: 4px 14px 150px; }
  .hero { padding: 30px 0 26px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-right { justify-content: space-between; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .upload-panel { left: 14px; right: 14px; width: auto; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  .btn { min-height: 46px; padding: 12px 20px; }
  .file-grid.list-mode .file-name { max-width: 140px; }
}

/* Light mode fallback, in case a viewer forces it (design is dark-first by intent) */
:root[data-theme="light"] {
  --bg: #f5f2ee;
  --text: #1c1a19;
  --text-dim: #55504c;
  --text-faint: #8a8480;
  --surface: rgba(0,0,0,0.035);
  --surface-strong: rgba(0,0,0,0.06);
  --border: rgba(0,0,0,0.1);
  --border-strong: rgba(0,0,0,0.18);
}
:root[data-theme="light"] .hero-title { background: linear-gradient(180deg, #1c1a19, #55504c); -webkit-background-clip: text; background-clip: text; }
:root[data-theme="light"] .modal { background: #fff; }
:root[data-theme="light"] .preview-body { background: #000; }
