:root {
  --bg: #0a0a0a;
  --fg: #eee;
  --accent: #ff4fd8;
  --card-bg: #111;
  --border: #222;
}


body.light {
  --bg: #f5f5f5;
  --fg: #111111;
  --accent: #ff4fd8;
  --card-bg: #d6d6d6ff;
  --border: #222;
}

body {
  background: var(--bg);
  margin: 0;
  font-family: system-ui;
  color: var(--fg);
}

header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  backdrop-filter: blur(10px);
  /*background: rgba(0,0,0,0.7);*/
  z-index: 10;

  font-size: 1.3rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-right {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 0.85rem;
}

.logo {
  font-size: 1.3rem;
  font-weight: bold;
}
.logo span { color: var(--accent); }

.feed {
  max-width: 1150px;
  margin: 20px auto;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px,1fr));
  gap: 10px;
}

.item {
  position: relative;
  padding-top: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: var(--card-bg);
}

.item img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: .2s ease;
}

.item img:hover {
  transform: scale(1.08);
}

.ui {
  position: absolute;
  bottom: 6px;
  left: 6px;
  right: 6px;
  display: flex;
  justify-content: space-between;
  font-size: .8rem;
  background: rgba(0,0,0,0.45);
  padding: 4px 6px;
  border-radius: 6px;
}

.like-btn {
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
  position: relative;
}

/* Label-Handling */
.like-btn .label-like {
  display: inline;
}
.like-btn .label-unlike {
  display: none;
  margin-left: 4px;
  font-size: 0.75rem;
}

/* Wenn bereits geliked → beim Hover Dislike-Text zeigen */
.like-btn.liked:hover .label-like {
  display: none;
}
.like-btn.liked:hover .label-unlike {
  display: inline;
}

/* optischer Effekt bei aktivem Like */
.like-btn.liked {
  font-weight: 600;
  text-shadow: 0 0 6px rgba(255, 79, 216, 0.8);
}

.login-btn {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #444;
  color: var(--fg);
  text-decoration: none;
  font-size: 0.85rem;
}
.login-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.sentinel {
  text-align: center;
  padding: 20px;
  color: #999;
}

.theme-toggle {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;   
}

/* =========================
   GIF Modal (responsive)
========================= */
.gif-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;

  /* Zentrierung robust */
  display: flex;
  align-items: center;
  justify-content: center;

  /* Desktop-Padding, damit es nicht am Rand klebt */
  padding: 18px;
}

/* Hidden */
.gif-modal.hidden {
  display: none;
}

/* Backdrop */
.gif-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(4px);

  /* wichtig für Touch */
  pointer-events: auto;
}

/* Container */
.gif-modal-content {
  position: relative;
  z-index: 1;

  /* Desktop: großes Fenster, nicht fullscreen */
  width: min(1100px, 92vw);
  height: min(820px, 92vh);

  background: var(--card-bg);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  overflow: hidden;

  /* Schatten */
  box-shadow: 0 24px 80px rgba(0,0,0,0.55);

  /* Layout innen */
  display: flex;
  flex-direction: column;

  /* wichtig für Swipe/Touch */
  touch-action: pan-x pan-y;
}

/* Top bar */
.gif-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;

  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.25);
  backdrop-filter: blur(8px);
}

.gif-modal-title {
  flex: 1;
  min-width: 0;
  text-align: center;
}
.gif-modal-title-main {
  font-weight: 650;
  line-height: 1.1;
}
.gif-modal-title-sub {
  font-size: 0.85rem;
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gif-modal-header-actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.gif-modal-back,
.gif-modal-close,
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.35);
  color: var(--fg);
  cursor: pointer;
  display: grid;
  place-items: center;
  text-decoration: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.gif-modal-close {
  font-size: 20px;
}




.gif-modal-back {
  font-size: 26px;
  line-height: 1;
}

/* Body: media + sidebar (desktop) */
.gif-modal-body {
  flex: 1;
  min-height: 0;
  display: flex;
}

/* Media area */ /* Bildbereich nimmt maximalen Platz ein */
.gif-modal-media {
  flex: 1;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.20);

  /* verhindert “Bild klebt an UI” */
  min-height: 0;
}

/* Bild skaliert ohne Cropping */
.gif-modal-media img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* wichtig: kein Cropping */
  display: block;

  /* minimiert Flackern */
  image-rendering: auto;
}

/* Sidebar */
.gif-modal-side {
  width: 360px;
  border-left: 1px solid rgba(255,255,255,0.10);
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 12px;
}

.gif-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.gif-modal-stats {
  font-size: 0.95rem;
  opacity: 0.9;
}

.gif-modal-caption {
  font-size: 0.95rem;
  opacity: 0.9;
  line-height: 1.35;
  overflow: auto;
  padding-right: 4px;
}

/* Mobile bottom bar */
.gif-modal-bottom {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;

  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.28);
  backdrop-filter: blur(8px);
}

.gif-modal-bottom-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.95rem;
}




/* UI-Leiste unten */
.gif-modal-ui {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;

  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.25);
}



/* Modal Animation (sanft) */
@media (prefers-reduced-motion: no-preference) {
  .gif-modal-content {
    animation: cgModalIn 160ms ease-out;
  }
  @keyframes cgModalIn {
    from { transform: translateY(8px) scale(0.985); opacity: 0.0; }
    to   { transform: translateY(0)   scale(1);     opacity: 1.0; }
  }
}

/* Mobile/Tablet: Instagram-like fullscreen */
@media (max-width: 720px) {
  .gif-modal {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
  }

  .gif-modal-content {
    width: 100vw;
    /* iOS Safari Fix: sichtbare Höhe verwenden */
    height: 100svh;     /* best (visible viewport) */
    height: 100dvh;     /* fallback */
    height: 100vh;      /* fallback */
    max-height: 100svh;

    border-radius: 0;
    border: none;
  }

  .gif-modal-header {
    padding-top: calc(10px + env(safe-area-inset-top));
  }

  .gif-modal-header-actions .icon-btn,
  .gif-modal-close {
    width: 38px;
    height: 38px;
  }

  .gif-modal-side {
    display: none; /* Sidebar ausblenden */
  }

  .gif-modal-body {
    flex-direction: column;
  }

  .gif-modal-bottom {
    display: flex;
    padding-bottom: calc(10px + env(safe-area-inset-bottom) + 24px); /* Safari toolbar Puffer */
  }

  /* Safe-Area (iPhone Notch) */
  .gif-modal-close {
    top: calc(12px + env(safe-area-inset-top));
    right: calc(12px + env(safe-area-inset-right));
    z-index: 2;
  }

  /* UI etwas größer für Touch */
  .gif-modal-ui {
    /*padding: 14px 16px;*/

    /* Safe-area + extra “Safari Toolbar”-Puffer */
    padding-bottom: calc(14px + env(safe-area-inset-bottom) + 28px);
    font-size: 0.95rem;
  }
}

/* Scroll-Lock (nur overflow, NICHT touch-action none – sonst killt es Swipes) */
body.modal-open {
  overflow: hidden;
  touch-action: none; /* verhindert “scroll behind” auf Mobile */
}