:root {
  color-scheme: dark;
  --bg: #07090e;
  --panel: rgba(15, 19, 27, .82);
  --panel-solid: #121822;
  --panel-soft: #1a2230;
  --text: #f7f9fc;
  --muted: #a5afbd;
  --line: rgba(255, 255, 255, .12);
  --pink: #ff4fa3;
  --cyan: #4fd8ff;
  --green: #51d88a;
  --yellow: #f3c760;
  --red: #ff6868;
  --shadow: 0 24px 80px rgba(0, 0, 0, .42);
  --nav-height: 70px;
  --stage-width: min(520px, calc((100svh - 8px) * 9 / 16));
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 16% 8%, rgba(79, 216, 255, .14), transparent 34%),
    radial-gradient(circle at 88% 12%, rgba(255, 79, 163, .18), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.app-shell,
.view-stack,
.view {
  width: 100%;
  height: 100%;
}

.view-stack {
  position: relative;
}

.view {
  display: none;
}

.view-active {
  display: block;
}

.glass {
  background: rgba(10, 13, 20, .54);
  border: 1px solid var(--line);
  box-shadow: 0 14px 48px rgba(0, 0, 0, .22);
  backdrop-filter: blur(18px);
}

.topbar {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  z-index: 30;
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 10px;
  width: min(var(--stage-width), calc(100% - 24px));
  transform: translateX(-50%);
  border-radius: 8px;
  padding: 8px;
  transition: transform .24s ease, opacity .24s ease;
}

.topbar.collapsed {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -118%);
}

.topbar-peek {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  z-index: 31;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 30px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(10,13,20,.62);
  color: var(--text);
  backdrop-filter: blur(14px);
  cursor: pointer;
}

.icon-button,
.nav-item,
.nav-post {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  cursor: pointer;
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .07);
  transition: background .18s ease, transform .18s ease;
}

.icon-button:active,
.nav-item:active,
.nav-post:active,
.action-button:active .bubble {
  transform: scale(.94);
}

.icon-button svg,
.nav-item svg,
.nav-post svg {
  width: 21px;
  height: 21px;
  stroke-width: 2.2;
}

.feed-tabs,
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
  min-width: 0;
}

.feed-tab,
.segment {
  min-width: 0;
  height: 34px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.feed-tab.active,
.segment.active {
  background: linear-gradient(135deg, rgba(255, 79, 163, .92), rgba(79, 216, 255, .84));
  color: #fff;
}

.feed {
  height: 100%;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior-y: contain;
  background: #000;
}

.feed::-webkit-scrollbar {
  display: none;
}

.video-slide {
  position: relative;
  height: 100svh;
  min-height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow: hidden;
  background: #06070a;
  isolation: isolate;
  animation: slideIn .24s ease both;
}

.video-slide video,
.poster-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.poster-fallback {
  background-position: center;
  background-size: cover;
  filter: brightness(.82);
}

.video-gradient {
  position: absolute;
  inset: auto 0 0;
  height: 44%;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .78));
  pointer-events: none;
}

.video-actions {
  position: absolute;
  right: max(12px, calc((100vw - var(--stage-width)) / 2 + 12px));
  bottom: calc(var(--nav-height) + 36px);
  z-index: 8;
  display: grid;
  gap: 11px;
}

.action-button {
  display: grid;
  justify-items: center;
  gap: 4px;
  color: #fff;
  background: transparent;
  cursor: pointer;
  text-shadow: 0 2px 10px rgba(0,0,0,.4);
}

.action-button .bubble,
.avatar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .18);
  backdrop-filter: blur(8px);
  transition: background .18s ease, color .18s ease, transform .18s ease;
}

.action-button.liked .bubble {
  color: var(--pink);
  background: rgba(255, 79, 163, .18);
  box-shadow: 0 0 0 6px rgba(255,79,163,.08);
}

.action-button.saved .bubble {
  color: var(--cyan);
  background: rgba(79, 216, 255, .18);
  box-shadow: 0 0 0 6px rgba(79,216,255,.08);
}

.action-button span {
  max-width: 60px;
  overflow: hidden;
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar-button {
  overflow: hidden;
  padding: 0;
  cursor: pointer;
}

.avatar-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-meta {
  position: absolute;
  left: max(16px, calc((100vw - var(--stage-width)) / 2 + 16px));
  right: max(76px, calc((100vw - var(--stage-width)) / 2 + 76px));
  bottom: calc(var(--nav-height) + 38px);
  z-index: 7;
  display: grid;
  gap: 8px;
  max-width: 520px;
  text-shadow: 0 2px 12px rgba(0,0,0,.45);
}

.creator-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-weight: 900;
  font-size: clamp(18px, 3.2vw, 25px);
  line-height: 1.08;
}

.verified {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--cyan);
  color: #05111a;
}

.description {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  font-size: clamp(13px, 2.4vw, 16px);
  line-height: 1.36;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: min(360px, 100%);
}

.tag-pill {
  border-radius: 999px;
  background: rgba(255, 255, 255, .15);
  color: #fff;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,.08);
  transition: background .18s ease, transform .18s ease;
}

.tag-pill:active {
  transform: scale(.96);
}

.tag-more {
  background: rgba(79,216,255,.18);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  width: min(var(--stage-width), calc(100% - 18px));
  height: 56px;
  transform: translateX(-50%);
  border-radius: 10px;
  padding: 5px;
  background: linear-gradient(180deg, rgba(22,20,28,.68), rgba(11,13,18,.78));
}

.nav-item {
  height: 46px;
  flex-direction: column;
  gap: 2px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}

.nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, .08);
}

.nav-post {
  width: 54px;
  height: 38px;
  justify-self: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--pink), var(--cyan));
  box-shadow: 0 8px 24px rgba(79,216,255,.18);
  transition: transform .18s ease;
}

.page-content {
  width: min(1180px, calc(100% - 24px));
  height: 100%;
  margin: 0 auto;
  overflow-y: auto;
  padding: 28px 0 calc(var(--nav-height) + 24px);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.section-header h1,
.auth-card h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.search-box {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 10px;
  height: 52px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 0 14px;
}

.search-box input,
.form-card input,
.form-card select {
  width: 100%;
  border: 1px solid var(--line);
  outline: none;
  background: rgba(255, 255, 255, .06);
  color: var(--text);
  border-radius: 8px;
}

.search-box input {
  height: 100%;
  border: 0;
  background: transparent;
  font-size: 16px;
}

.segmented {
  width: min(420px, 100%);
  margin-bottom: 18px;
}

.search-panel.hidden,
.hidden {
  display: none !important;
}

.tag-cloud {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

.tag-card {
  position: relative;
  display: flex;
  align-items: end;
  justify-content: space-between;
  aspect-ratio: 9 / 16;
  min-height: 238px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px;
  cursor: pointer;
  text-align: left;
  isolation: isolate;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.tag-card:hover,
.grid-card:hover,
.leader-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,.22);
}

.tag-card::before {
  position: absolute;
  inset: 0;
  z-index: -2;
  background-image: var(--tag-image);
  background-position: center;
  background-size: cover;
  content: "";
  filter: saturate(1.08);
  transform: scale(1.04);
}

.tag-card::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(7,9,14,.08), rgba(7,9,14,.22) 42%, rgba(7,9,14,.82));
  content: "";
}

.tag-card strong {
  display: block;
  margin-bottom: 5px;
  color: var(--pink);
  font-size: 16px;
}

.tag-card span {
  display: block;
  min-width: 0;
}

.tag-card small {
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.tag-card svg {
  flex: 0 0 auto;
  color: rgba(255,255,255,.82);
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.grid-card {
  position: relative;
  aspect-ratio: 9 / 16;
  min-height: 0;
  overflow: hidden;
  border-radius: 8px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform .2s ease, border-color .2s ease;
}

.grid-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .25s ease;
}

.grid-card:hover img {
  transform: scale(1.05);
}

.grid-info {
  position: absolute;
  inset: auto 0 0;
  padding: 44px 10px 10px;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.82));
}

.grid-info strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid-info span {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.leaderboard {
  display: grid;
  gap: 10px;
}

.leader-card,
.creator-profile,
.profile-card,
.form-card,
.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.leader-card {
  display: grid;
  grid-template-columns: 42px 54px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  cursor: pointer;
  transition: transform .2s ease, border-color .2s ease, background .2s ease;
}

.leader-card.top-1 {
  border-color: rgba(243,199,96,.54);
  background: linear-gradient(135deg, rgba(243,199,96,.18), rgba(18,24,34,.88));
}

.leader-card.top-2 {
  border-color: rgba(192,205,218,.48);
  background: linear-gradient(135deg, rgba(192,205,218,.14), rgba(18,24,34,.88));
}

.leader-card.top-3 {
  border-color: rgba(220,146,90,.48);
  background: linear-gradient(135deg, rgba(220,146,90,.14), rgba(18,24,34,.88));
}

.leader-rank {
  color: var(--yellow);
  font-size: 22px;
  font-weight: 950;
}

.leader-avatar,
.profile-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--cyan));
  color: #fff;
  font-weight: 950;
}

.leader-avatar {
  width: 54px;
  height: 54px;
}

.leader-avatar img,
.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.leader-metric {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.centered-page {
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(440px, 100%);
  padding: 28px;
  text-align: center;
}

.auth-card p {
  color: var(--muted);
}

.auth-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin-bottom: 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255,79,163,.28), rgba(79,216,255,.24));
}

.primary-action {
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--pink), var(--cyan));
  color: #fff;
  cursor: pointer;
  font-weight: 900;
  padding: 0 18px;
}

.auth-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-card {
  padding: 18px;
}

.form-card h2 {
  margin: 0 0 14px;
}

.form-card label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.form-card input {
  height: 42px;
  padding: 0 11px;
}

.form-card .primary-action {
  width: 100%;
  margin-top: 16px;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.iti {
  width: 100%;
}

.profile-card,
.creator-profile {
  padding: 18px;
}

.profile-hero,
.creator-profile {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  font-size: 28px;
}

.profile-hero h2,
.creator-profile h2 {
  margin: 0 0 4px;
}

.profile-hero p,
.creator-profile p {
  margin: 0;
  color: var(--muted);
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.profile-stats div {
  border-radius: 8px;
  background: rgba(255, 255, 255, .06);
  padding: 12px;
}

.profile-stats strong {
  display: block;
  font-size: 22px;
}

.profile-stats span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.creator-profile {
  margin-bottom: 16px;
}

.creator-profile .profile-avatar {
  box-shadow: 0 14px 44px rgba(255,79,163,.2);
}

.creator-copy {
  min-width: min(220px, 100%);
  flex: 1 1 220px;
}

.creator-stat {
  min-width: 86px;
  border-radius: 8px;
  background: rgba(255,255,255,.06);
  padding: 10px 12px;
}

.creator-stat strong,
.creator-stat small {
  display: block;
}

.creator-stat strong {
  font-size: 20px;
}

.creator-stat small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.profile-library {
  margin-top: 16px;
}

.profile-tabs {
  margin-bottom: 14px;
}

.heart-burst,
.tap-hint {
  position: absolute;
  left: 50%;
  top: 48%;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.heart-burst {
  color: var(--pink);
  filter: drop-shadow(0 12px 32px rgba(0,0,0,.45));
  animation: heartBurst .78s ease both;
}

.heart-burst svg {
  width: 112px;
  height: 112px;
  fill: currentColor;
}

.tap-hint {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: rgba(0,0,0,.38);
  color: #fff;
  backdrop-filter: blur(8px);
  animation: tapHint .58s ease both;
}

.tap-hint svg {
  width: 38px;
  height: 38px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-height) + 20px);
  z-index: 60;
  width: min(420px, calc(100% - 24px));
  transform: translateX(-50%);
  border-radius: 8px;
  background: rgba(10, 13, 20, .9);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.empty-state,
.loader {
  display: grid;
  place-items: center;
  min-height: 240px;
  color: var(--muted);
  text-align: center;
}

@media (min-width: 760px) {
  .feed {
    display: grid;
    justify-items: center;
  }

  .video-slide {
    width: var(--stage-width);
    margin: 0 auto;
    border-inline: 1px solid rgba(255,255,255,.08);
  }

  .topbar {
    top: 18px;
  }

  .bottom-nav {
    bottom: 16px;
  }
}

@media (max-width: 760px) {
  :root {
    --nav-height: 68px;
    --stage-width: 100vw;
  }

  .page-content {
    width: calc(100% - 18px);
    padding-top: 20px;
  }

  .auth-layout,
  .two-col {
    grid-template-columns: 1fr;
  }

  .video-actions {
    right: 10px;
    bottom: calc(var(--nav-height) + 78px);
  }

  .video-meta {
    left: 14px;
    right: 74px;
    bottom: calc(var(--nav-height) + 36px);
  }

  .leader-card {
    grid-template-columns: 36px 48px 1fr;
  }

  .leader-metric {
    grid-column: 3;
  }
}

@media (max-width: 420px) {
  .topbar {
    grid-template-columns: 38px 1fr 38px;
    gap: 6px;
    padding: 6px;
  }

  .feed-tab,
  .segment {
    font-size: 12px;
  }

  .nav-item span {
    display: none;
  }

  .bottom-nav {
    height: 54px;
  }

  .action-button .bubble,
  .avatar-button {
    width: 42px;
    height: 42px;
  }

  .tag-row {
    gap: 5px;
  }
}

@keyframes slideIn {
  from {
    opacity: .72;
  }
  to {
    opacity: 1;
  }
}

@keyframes heartBurst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(.42) rotate(-8deg);
  }
  30% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08) rotate(4deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -62%) scale(1.32) rotate(0);
  }
}

@keyframes tapHint {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(.72);
  }
  25% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.08);
  }
}
