:root {
  --bg: #FFFBF7;
  --bg-2: #FFF4EC;
  --text: #3D2C2E;
  --text-muted: #7A6567;
  --accent-coral: #FF9AA2;
  --accent-peach: #FFB7B2;
  --accent-mint: #B5EAD7;
  --accent-lavender: #C7CEEA;
  --accent-sky: #A0E7E5;
  --accent-yellow: #FFDAC1;
  --shadow: 0 10px 30px rgba(61, 44, 46, 0.12);
  --shadow-hover: 0 20px 50px rgba(61, 44, 46, 0.22);
  --radius: 28px;
  --particle-desktop: 220px;
  --particle-tablet: 170px;
  --particle-mobile: 130px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Nunito', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: radial-gradient(circle at 20% 20%, var(--bg-2), var(--bg) 60%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Login */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 30%, var(--bg-2), var(--bg) 70%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  text-align: center;
  padding: 48px 36px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 2px solid rgba(255, 255, 255, 0.6);
}

.login-icon {
  font-size: 72px;
  line-height: 1;
  margin-bottom: 16px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 2rem;
  font-weight: 900;
}

.login-card p {
  margin: 0 0 28px;
  color: var(--text-muted);
  font-size: 1.05rem;
}

.login-error {
  color: #D32F2F;
  background: #FFEBEE;
  padding: 12px 16px;
  border-radius: 14px;
  margin-bottom: 20px;
  font-weight: 700;
}

.login-card input[type="password"] {
  width: 100%;
  padding: 16px 18px;
  font-size: 1.1rem;
  border: 2px solid var(--accent-lavender);
  border-radius: 16px;
  background: #fff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  margin-bottom: 16px;
  font-family: inherit;
}

.login-card input[type="password"]:focus {
  border-color: var(--accent-coral);
  box-shadow: 0 0 0 4px rgba(255, 154, 162, 0.2);
}

.login-card button {
  width: 100%;
  padding: 16px 24px;
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-coral), var(--accent-peach));
  border: none;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(255, 154, 162, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

.login-card button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(255, 154, 162, 0.45);
}

.login-card button:active {
  transform: translateY(0);
}

/* Header */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  text-align: center;
  padding: 22px 16px 18px;
  pointer-events: none;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(1.6rem, 5vw, 2.6rem);
  font-weight: 900;
  color: var(--text);
  text-shadow: 0 2px 10px rgba(255, 255, 255, 0.8);
}

.site-header .subtitle {
  margin: 4px 0 0;
  font-size: clamp(0.95rem, 3vw, 1.2rem);
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.7);
  display: inline-block;
  padding: 6px 16px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}

.header-actions {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
  pointer-events: auto;
  z-index: 110;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(6px);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(61, 44, 46, 0.12);
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
}

.icon-btn:hover {
  background: #fff;
  transform: scale(1.08);
  box-shadow: 0 5px 16px rgba(61, 44, 46, 0.18);
}

.icon-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

/* Stage */
#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 1;
}

/* Particles */
.particle {
  position: absolute;
  width: var(--particle-desktop);
  height: calc(var(--particle-desktop) * 0.75);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: #fff;
  box-shadow: var(--shadow);
  border: 4px solid transparent;
  will-change: transform;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-drag: none;
  transition: box-shadow 0.25s, transform 0.25s, border-color 0.25s;
}

.particle::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0) 60%, rgba(0,0,0,0.25) 100%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s;
}

.particle img,
.particle video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}

.particle .label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 14px 16px 16px;
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
  background: linear-gradient(0deg, rgba(0,0,0,0.55), transparent);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.particle:hover,
.particle.hovered {
  z-index: 200 !important;
  box-shadow: var(--shadow-hover);
  transform: scale(1.08);
}

.particle:hover::after,
.particle.hovered::after {
  opacity: 1;
}

.particle:hover .label,
.particle.hovered .label {
  opacity: 1;
  transform: translateY(0);
}

/* Pastell-Rahmenfarben, zufällig per JS vergeben */
.particle.border-coral { border-color: var(--accent-coral); }
.particle.border-peach { border-color: var(--accent-peach); }
.particle.border-mint { border-color: var(--accent-mint); }
.particle.border-lavender { border-color: var(--accent-lavender); }
.particle.border-sky { border-color: var(--accent-sky); }
.particle.border-yellow { border-color: var(--accent-yellow); }

/* Gesehen-Markierung */
.watched-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--accent-mint);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  opacity: 0.85;
  pointer-events: none;
  z-index: 3;
  transition: opacity 0.2s, transform 0.2s;
}

.watched-badge svg {
  width: 14px;
  height: 14px;
  stroke-width: 3;
}

.particle:hover .watched-badge,
.particle.hovered .watched-badge {
  opacity: 1;
  transform: scale(1.1);
}

/* Reduced Motion / Fallback */
@media (prefers-reduced-motion: reduce) {
  .particle {
    transition: none;
  }
}

body.reduced-motion #stage {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  justify-content: center;
  padding: 120px 20px 40px;
  gap: 24px;
  overflow-y: auto;
}

body.reduced-motion .particle {
  position: relative;
  transform: none !important;
  top: auto !important;
  left: auto !important;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(61, 44, 46, 0.78);
  backdrop-filter: blur(8px);
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  z-index: 2;
  transition: transform 0.15s, background 0.15s;
}

.modal-close:hover {
  background: #fff;
  transform: scale(1.08);
}

.modal-title {
  margin: 0;
  padding: 20px 60px 14px 24px;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
}

.modal-media {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.modal-media video,
.modal-media img {
  max-width: 100%;
  max-height: 70vh;
  width: auto;
  height: auto;
  display: block;
}

.modal-media video {
  width: 100%;
  max-height: 70vh;
}

/* List Popup */
.list-popup {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.list-popup[hidden] {
  display: none;
}

.list-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(61, 44, 46, 0.65);
  backdrop-filter: blur(6px);
}

.list-popup-content {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

.list-popup-title {
  margin: 0;
  padding: 20px 60px 14px 22px;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
}

.item-list {
  list-style: none;
  margin: 0;
  padding: 0 14px 14px;
  overflow-y: auto;
}

.item-list-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
}

.item-list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid transparent;
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.item-list-row:hover,
.item-list-row:focus {
  background: #fff;
  border-color: var(--accent-coral);
  outline: none;
}

.item-list-row:active {
  transform: scale(0.99);
}

.item-list-thumb {
  width: 56px;
  height: 42px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-2);
}

.item-list-title {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-list-type {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-lavender);
  color: #fff;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Loading */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.4s, visibility 0.4s;
}

.loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-bubble {
  padding: 18px 28px;
  background: #fff;
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-weight: 700;
  color: var(--text-muted);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Responsive */
@media (max-width: 1024px) {
  .particle {
    width: var(--particle-tablet);
    height: calc(var(--particle-tablet) * 0.75);
  }
}

@media (max-width: 640px) {
  .particle {
    width: var(--particle-mobile);
    height: calc(var(--particle-mobile) * 0.75);
    border-width: 3px;
    border-radius: 20px;
  }
  .particle .label {
    font-size: 0.85rem;
    padding: 10px 12px 12px;
  }
  .modal-content {
    max-height: 96vh;
    border-radius: 20px;
  }
  .modal-title {
    font-size: 1.1rem;
    padding: 16px 52px 10px 16px;
  }
  .site-header {
    padding: 16px 12px 12px;
  }
  .header-actions {
    top: 10px;
    right: 10px;
    gap: 6px;
  }
  .icon-btn {
    width: 38px;
    height: 38px;
  }
  .icon-btn svg {
    width: 20px;
    height: 20px;
  }
  .list-popup-content {
    max-height: 85vh;
    border-radius: 20px;
  }
  .list-popup-title {
    font-size: 1.1rem;
    padding: 16px 52px 10px 16px;
  }
}
