:root {
  color-scheme: dark;
  --bg: #06070a;
  --panel: rgba(14, 16, 23, 0.78);
  --panel-strong: #10121a;
  --text: #f8fafc;
  --muted: #a8afbd;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #ff365f;
  --accent-2: #8b5cf6;
  --gold: #f6c76b;
  --safe-top: max(14px, env(safe-area-inset-top));
  --safe-bottom: max(16px, env(safe-area-inset-bottom));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { overflow: hidden; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.ambient {
  position: fixed;
  inset: auto;
  width: 42vw;
  height: 42vw;
  border-radius: 999px;
  filter: blur(100px);
  opacity: .13;
  pointer-events: none;
  z-index: 0;
}
.ambient-one { top: -18vw; left: -12vw; background: var(--accent-2); }
.ambient-two { right: -14vw; bottom: -20vw; background: var(--accent); }

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  height: 76px;
  padding: var(--safe-top) max(18px, calc((100vw - 1240px) / 2)) 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(180deg, rgba(6,7,10,.96), rgba(6,7,10,.72), transparent);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-width: 0; }
.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, rgba(255,54,95,.28), rgba(139,92,246,.22));
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 12px 35px rgba(0,0,0,.35);
  overflow: hidden;
}
.brand-logo img { width: 34px; height: 34px; object-fit: contain; }
.brand-copy { display: grid; min-width: 0; }
.brand-copy strong { font-size: 17px; letter-spacing: -.02em; }
.brand-copy small { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.genre-select, .admin-link {
  height: 38px;
  border: 1px solid var(--line);
  background: rgba(12,14,20,.76);
  color: var(--text);
  border-radius: 999px;
  backdrop-filter: blur(18px);
}
.genre-select { max-width: 180px; padding: 0 34px 0 14px; outline: none; }
.admin-link { width: 38px; display: grid; place-items: center; text-decoration: none; font-size: 22px; }

.category-nav {
  position: fixed;
  z-index: 31;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 740px);
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 8px 18px 12px;
  mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
}
.category-nav::-webkit-scrollbar { display: none; }
.category-chip {
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,.11);
  color: #d8dce5;
  background: rgba(10,12,18,.72);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(18px);
  transition: .2s ease;
}
.category-chip:hover { border-color: rgba(255,255,255,.26); transform: translateY(-1px); }
.category-chip.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(255,54,95,.94), rgba(139,92,246,.86));
  border-color: transparent;
  box-shadow: 0 10px 28px rgba(255,54,95,.24);
}

.feed {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100svh;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
}
.feed::-webkit-scrollbar { display: none; }
.tok-slide { height: 100svh; min-height: 600px; scroll-snap-align: start; scroll-snap-stop: always; display: grid; place-items: center; padding: 0; }
.video-shell {
  position: relative;
  width: min(100vw, 540px);
  height: 100svh;
  min-height: 600px;
  overflow: hidden;
  background: #0b0d13;
  isolation: isolate;
}
.video-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 20% 20%, rgba(139,92,246,.16), transparent 38%),
    radial-gradient(circle at 84% 74%, rgba(255,54,95,.13), transparent 44%),
    #090a0f;
}
.media-stage { position: absolute; inset: 0; display: grid; place-items: center; background: #08090d; }
.media-stage iframe, .media-stage video {
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: cover;
  background: #08090d;
}
.media-placeholder {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: saturate(.78);
}
.media-placeholder::after { content: ""; position: absolute; inset: 0; background: rgba(5,6,9,.42); backdrop-filter: blur(18px); }
.media-loader { position: relative; z-index: 2; width: 40px; height: 40px; border: 2px solid rgba(255,255,255,.15); border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.media-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(4,5,8,.62) 0%, transparent 24%, transparent 54%, rgba(4,5,8,.88) 92%),
    linear-gradient(90deg, transparent 60%, rgba(4,5,8,.27));
  z-index: 3;
}
.provider-pill {
  position: absolute;
  z-index: 5;
  top: 126px;
  right: 16px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.13);
  background: rgba(7,8,12,.62);
  color: rgba(255,255,255,.72);
  font-size: 10px;
  letter-spacing: .13em;
  text-transform: uppercase;
  backdrop-filter: blur(14px);
}
.slide-copy {
  position: absolute;
  z-index: 5;
  left: 18px;
  right: 94px;
  bottom: calc(var(--safe-bottom) + 32px);
  text-shadow: 0 3px 18px rgba(0,0,0,.62);
}
.meta-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.category-badge {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
  background: linear-gradient(135deg, var(--accent), #f97316);
  box-shadow: 0 8px 20px rgba(255,54,95,.24);
}
.genre-line { color: rgba(255,255,255,.76); font-size: 12px; }
.slide-title { margin: 0; font-size: clamp(23px, 5vw, 32px); line-height: 1.05; letter-spacing: -.035em; }
.slide-author { margin: 8px 0 0; font-weight: 700; font-size: 13px; color: #fff; }
.slide-description { margin: 8px 0 0; color: rgba(255,255,255,.78); font-size: 13px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.action-rail {
  position: absolute;
  z-index: 6;
  right: 14px;
  bottom: calc(var(--safe-bottom) + 36px);
  display: grid;
  gap: 14px;
}
.rail-button {
  width: 68px;
  border: 0;
  padding: 0;
  color: #fff;
  background: transparent;
  cursor: pointer;
  display: grid;
  justify-items: center;
  gap: 6px;
}
.rail-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(12,14,20,.72);
  backdrop-filter: blur(18px);
  box-shadow: 0 12px 30px rgba(0,0,0,.28);
  transition: transform .18s ease, background .18s ease;
}
.rail-button:hover .rail-icon { transform: translateY(-2px) scale(1.04); }
.content-button .rail-icon { background: linear-gradient(145deg, rgba(255,54,95,.96), rgba(139,92,246,.88)); border-color: transparent; }
.rail-label { max-width: 70px; font-size: 10px; line-height: 1.1; text-shadow: 0 2px 8px #000; }
.swipe-hint { position: absolute; z-index: 5; left: 50%; bottom: calc(var(--safe-bottom) + 4px); transform: translateX(-50%); color: rgba(255,255,255,.48); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; display: flex; align-items: center; gap: 6px; }
.swipe-hint span { width: 4px; height: 4px; background: var(--accent); border-radius: 50%; box-shadow: 0 0 12px var(--accent); }

.whatsapp-float {
  position: fixed;
  z-index: 40;
  right: max(18px, env(safe-area-inset-right));
  top: 18px;
  min-height: 42px;
  padding: 0 16px;
  display: none;
  align-items: center;
  gap: 9px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 999px;
  color: #fff;
  background: rgba(12,14,20,.84);
  backdrop-filter: blur(20px);
  cursor: pointer;
  box-shadow: 0 14px 38px rgba(0,0,0,.35);
}
.whatsapp-dot { width: 9px; height: 9px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 5px rgba(34,197,94,.12); }

.loading-state, .empty-state {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  padding: 24px;
  background: radial-gradient(circle at center, rgba(28,23,45,.68), rgba(6,7,10,.96));
}
.loading-orbit { width: 52px; height: 52px; border-radius: 50%; border: 2px solid rgba(255,255,255,.12); border-top-color: var(--accent); border-right-color: var(--accent-2); animation: spin .9s linear infinite; margin-bottom: 18px; }
.loading-state span { color: var(--muted); font-size: 13px; }
.empty-state { z-index: 19; }
.empty-icon { width: 62px; height: 62px; display: grid; place-items: center; border-radius: 22px; background: linear-gradient(145deg, rgba(255,54,95,.25), rgba(139,92,246,.22)); font-size: 26px; }
.empty-state h1 { margin: 18px 0 8px; font-size: 25px; }
.empty-state p { margin: 0 0 20px; color: var(--muted); }
.empty-state button { border: 0; border-radius: 999px; padding: 11px 18px; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); cursor: pointer; }

.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3,4,7,.82);
  backdrop-filter: blur(28px);
}
.gate-card {
  width: min(100%, 440px);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 30px;
  padding: 30px;
  background: linear-gradient(155deg, rgba(22,24,34,.98), rgba(10,11,17,.98));
  box-shadow: 0 28px 90px rgba(0,0,0,.55);
}
.gate-logo { width: 58px; height: 58px; border-radius: 20px; display: grid; place-items: center; background: linear-gradient(145deg, rgba(255,54,95,.25), rgba(139,92,246,.2)); border: 1px solid rgba(255,255,255,.12); margin-bottom: 20px; }
.gate-logo img { width: 45px; height: 45px; object-fit: contain; }
.eyebrow { color: var(--gold); font-size: 10px; letter-spacing: .16em; font-weight: 800; }
.gate-card h1 { margin: 8px 0; font-size: 30px; letter-spacing: -.04em; }
.gate-card > p { color: var(--muted); line-height: 1.55; margin: 0 0 22px; }
.gate-card label { display: block; font-size: 12px; color: #d9dde6; margin-bottom: 8px; }
.code-row { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
.code-row input { min-width: 0; border: 1px solid rgba(255,255,255,.12); border-radius: 14px; background: #090b10; color: #fff; padding: 13px 14px; outline: none; }
.code-row input:focus { border-color: rgba(255,54,95,.7); box-shadow: 0 0 0 3px rgba(255,54,95,.1); }
.code-row button, .gate-whatsapp { border: 0; border-radius: 14px; padding: 0 18px; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); cursor: pointer; font-weight: 750; }
.form-message { min-height: 20px; margin: 9px 0 0 !important; font-size: 12px; color: #fb7185 !important; }
.gate-whatsapp { width: 100%; min-height: 44px; margin-top: 12px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.1); }

@media (min-width: 800px) {
  body::before, body::after { content: ""; position: fixed; top: 0; bottom: 0; width: calc((100vw - 540px) / 2); z-index: 1; pointer-events: none; }
  body::before { left: 0; background: radial-gradient(circle at right center, rgba(139,92,246,.08), transparent 60%); }
  body::after { right: 0; background: radial-gradient(circle at left center, rgba(255,54,95,.08), transparent 60%); }
  .video-shell { border-left: 1px solid rgba(255,255,255,.07); border-right: 1px solid rgba(255,255,255,.07); box-shadow: 0 0 80px rgba(0,0,0,.45); }
  .whatsapp-float { display: flex; }
}

@media (max-width: 620px) {
  .topbar { height: 68px; padding-left: 14px; padding-right: 14px; }
  .brand-logo { width: 38px; height: 38px; border-radius: 13px; }
  .brand-logo img { width: 31px; height: 31px; }
  .brand-copy small { max-width: 155px; }
  .genre-select { width: 43px; max-width: 43px; color: transparent; padding: 0; background-image: radial-gradient(circle, #fff 1.5px, transparent 2px); background-size: 6px 6px; background-position: center; background-repeat: no-repeat; }
  .admin-link { display: none; }
  .category-nav { top: 64px; padding-left: 14px; padding-right: 14px; }
  .provider-pill { top: 112px; }
  .slide-copy { left: 15px; right: 88px; }
  .action-rail { right: 9px; }
  .rail-button { width: 66px; }
  .gate-card { padding: 24px; border-radius: 25px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* =========================================================
   COMUNITOK 1.1 · AUDIO, EMBED OFICIAL Y AJUSTE RESPONSIVE
   ========================================================= */
.top-actions {
  margin-right: 112px;
}

.whatsapp-float {
  display: flex;
  top: max(12px, env(safe-area-inset-top));
  min-height: 40px;
  padding: 0 15px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.action-rail {
  top: 174px;
  bottom: auto;
  right: 12px;
  gap: 10px;
}

.rail-button {
  width: 62px;
  gap: 5px;
}

.rail-icon {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  font-size: 15px;
}

.audio-button .rail-icon {
  background: rgba(12,14,20,.78);
}

.audio-button.sound-on .rail-icon {
  border-color: rgba(45,212,191,.46);
  background: linear-gradient(145deg, rgba(13,148,136,.92), rgba(37,99,235,.78));
  box-shadow: 0 12px 30px rgba(13,148,136,.2);
}

.rail-label {
  max-width: 64px;
  font-size: 9.5px;
  font-weight: 650;
}

.slide-copy {
  right: 18px;
  bottom: calc(var(--safe-bottom) + 70px);
  max-width: 460px;
  pointer-events: none;
}

.slide-title {
  font-size: clamp(22px, 4.7vw, 30px);
}

.slide-description {
  margin-top: 6px;
  -webkit-line-clamp: 2;
}

/* Publicación completa oficial de TikTok */
.tok-slide.is-full-embed .media-stage {
  display: block;
  padding: 112px 10px 12px;
  overflow: hidden;
  background: #05060a;
}

.tiktok-embed-host {
  position: relative;
  z-index: 2;
  width: 100%;
  height: calc(100svh - 124px);
  min-height: 470px;
  display: grid;
  place-items: start center;
  overflow: hidden;
}

.tiktok-embed-host .tiktok-embed {
  width: min(100%, 500px) !important;
  max-width: 500px !important;
  min-width: 280px !important;
  margin: 0 auto !important;
}

.tok-slide.is-full-embed .tiktok-embed-host iframe {
  width: 100% !important;
  height: min(690px, calc(100svh - 126px)) !important;
  max-height: calc(100svh - 126px) !important;
  object-fit: initial;
  border-radius: 16px;
}

.tok-slide.is-full-embed .media-vignette {
  background: linear-gradient(180deg, rgba(4,5,8,.58) 0%, transparent 18%, transparent 86%, rgba(4,5,8,.32) 100%);
}

.tok-slide.is-full-embed .slide-copy {
  display: none;
}

.tok-slide.is-full-embed .provider-pill {
  top: 118px;
}

.tok-slide.is-full-embed .action-rail {
  top: 158px;
}

@media (max-width: 620px) {
  .topbar {
    padding-left: 10px;
    padding-right: 10px;
  }

  .top-actions {
    margin-right: 82px;
    gap: 5px;
  }

  .genre-select {
    width: 96px;
    max-width: 96px;
    height: 36px;
    color: #fff;
    padding: 0 25px 0 10px;
    font-size: 11px;
    background-image: none;
  }

  .whatsapp-float {
    right: max(8px, env(safe-area-inset-right));
    top: max(10px, env(safe-area-inset-top));
    min-height: 36px;
    padding: 0 11px;
    gap: 7px;
    font-size: 11px;
  }

  .whatsapp-dot {
    width: 8px;
    height: 8px;
    box-shadow: 0 0 0 4px rgba(34,197,94,.12);
  }

  .provider-pill {
    top: 116px;
    right: 10px;
    padding: 5px 8px;
    font-size: 9px;
  }

  .action-rail {
    top: 154px;
    right: 7px;
    gap: 8px;
  }

  .rail-button {
    width: 56px;
  }

  .rail-icon {
    width: 41px;
    height: 41px;
    border-radius: 15px;
    font-size: 14px;
  }

  .rail-label {
    max-width: 56px;
    font-size: 9px;
  }

  .slide-copy {
    left: 14px;
    right: 14px;
    bottom: calc(var(--safe-bottom) + 64px);
    max-width: none;
  }

  .meta-line {
    margin-bottom: 8px;
  }

  .category-badge {
    padding: 5px 9px;
    font-size: 10px;
  }

  .genre-line {
    font-size: 11px;
  }

  .slide-title {
    max-width: calc(100% - 2px);
    font-size: clamp(20px, 6.8vw, 26px);
    line-height: 1.07;
  }

  .slide-author {
    margin-top: 6px;
    font-size: 12px;
  }

  .slide-description {
    margin-top: 5px;
    font-size: 12px;
    line-height: 1.35;
    -webkit-line-clamp: 2;
  }

  .tok-slide.is-full-embed .media-stage {
    padding: 108px 5px 8px;
  }

  .tiktok-embed-host {
    height: calc(100svh - 116px);
    min-height: 440px;
  }

  .tiktok-embed-host .tiktok-embed {
    min-width: 270px !important;
  }

  .tok-slide.is-full-embed .tiktok-embed-host iframe {
    height: calc(100svh - 118px) !important;
    max-height: calc(100svh - 118px) !important;
    border-radius: 12px;
  }

  .tok-slide.is-full-embed .provider-pill {
    top: 112px;
  }

  .tok-slide.is-full-embed .action-rail {
    top: 148px;
  }
}

@media (max-width: 420px) {
  .brand-copy small {
    display: none;
  }

  .brand-copy strong {
    font-size: 15px;
  }

  .brand-logo {
    width: 36px;
    height: 36px;
  }

  .top-actions {
    margin-right: 78px;
  }

  .genre-select {
    width: 86px;
    max-width: 86px;
  }

  .whatsapp-float {
    padding: 0 9px;
  }
}

@media (max-height: 650px) {
  .provider-pill {
    top: 108px;
  }

  .action-rail {
    top: 143px;
    gap: 6px;
  }

  .rail-icon {
    width: 39px;
    height: 39px;
    border-radius: 14px;
  }

  .slide-copy {
    bottom: calc(var(--safe-bottom) + 48px);
  }

  .slide-title {
    font-size: 20px;
  }

  .slide-description {
    font-size: 11px;
    -webkit-line-clamp: 1;
  }

  .tok-slide.is-full-embed .media-stage {
    padding-top: 102px;
  }

  .tok-slide.is-full-embed .provider-pill {
    top: 106px;
  }

  .tok-slide.is-full-embed .action-rail {
    top: 139px;
  }
}

/* =========================================================
   COMUNITOK 1.2 · POSICIÓN REAL, CONTROLES Y CACHE BUST
   ========================================================= */
.action-rail {
  top: 174px !important;
  bottom: auto !important;
  right: 12px !important;
  z-index: 8;
}

.slide-copy {
  bottom: calc(var(--safe-bottom) + 92px) !important;
  right: 82px !important;
}

.slide-title {
  font-size: clamp(21px, 4vw, 27px) !important;
  line-height: 1.08 !important;
  -webkit-line-clamp: 2;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.slide-description {
  font-size: 12px !important;
  line-height: 1.35 !important;
  -webkit-line-clamp: 1 !important;
}

/* Deja libre la franja inferior para pausa, volumen y progreso de TikTok. */
.media-stage iframe {
  pointer-events: auto;
}

@media (max-width: 620px) {
  .action-rail {
    top: 150px !important;
    right: 7px !important;
  }

  .slide-copy {
    left: 14px !important;
    right: 76px !important;
    bottom: calc(var(--safe-bottom) + 86px) !important;
  }

  .slide-title {
    font-size: clamp(19px, 6vw, 23px) !important;
  }

  .slide-description {
    font-size: 11px !important;
  }
}

@media (max-height: 650px) {
  .action-rail {
    top: 138px !important;
  }

  .slide-copy {
    bottom: calc(var(--safe-bottom) + 76px) !important;
  }
}
