:root {
  --bg-black: #000000;
  --bg-navy: #0f1727;
  --bg-card: #161f33;
  --accent-green: #25d366;
  --accent-red: #fe2c55;
  --accent-cyan: #25f4ee;
  --text-main: #ffffff;
  --text-muted: #9ca3af;
  --border-subtle: rgba(255, 255, 255, 0.1);
  --font-stack: 'Vazirmatn', 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--font-stack);
}

html, body {
  width: 100%;
  height: 100%;
  background-color: #05070c;
  color: var(--text-main);
  overflow: hidden;
  user-select: none;
}

.hidden {
  display: none !important;
}

/* Splash Screen */
.splash-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-navy);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  transition: opacity 0.4s ease;
}

.splash-logo-wrap {
  animation: logoPulse 1.4s infinite ease-in-out;
}

.splash-logo-wrap img {
  width: 96px;
  height: 96px;
  object-fit: contain;
}

.splash-brand {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--accent-green);
}

@keyframes logoPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.85; }
}

/* App Shell (Mobile Fullscreen / Desktop Centered Phone Frame) */
.app-shell {
  position: relative;
  width: 100%;
  height: 100dvh;
  max-width: 440px;
  margin: 0 auto;
  background: var(--bg-black);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@media (min-width: 500px) {
  .app-shell {
    height: 96dvh;
    margin-top: 2dvh;
    border-radius: 24px;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85);
  }
}

.page-view {
  position: relative;
  flex: 1;
  height: calc(100% - 58px);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.page-view.active {
  display: flex;
}

/* Top Feed Header */
.feed-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  height: 56px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(to bottom, rgba(0,0,0,0.65), transparent);
}

.feed-tabs {
  display: flex;
  align-items: center;
  gap: 14px;
}

.feed-tab {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  padding: 6px 2px;
  transition: color 0.2s;
}

.feed-tab.active {
  color: #ffffff;
}

.feed-tab.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 20%;
  right: 20%;
  height: 3px;
  border-radius: 2px;
  background: #ffffff;
}

.tab-divider {
  width: 1px;
  height: 12px;
  background: rgba(255, 255, 255, 0.25);
}

.ws-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6b7280;
}

.ws-dot.online {
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

/* TikTok Vertical Snap Feed */
.feed-container {
  width: 100%;
  height: 100%;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}

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

.video-slide {
  position: relative;
  width: 100%;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: #000000;
  overflow: hidden;
}

.video-slide video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-gradient-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 42%;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.35) 55%, transparent 100%);
  pointer-events: none;
}

/* Pause Indicator & 2x Speed Pill */
.pause-overlay-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.9);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
}

.pause-overlay-icon.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.speed-2x-pill {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 39, 0.88);
  border: 1px solid var(--accent-green);
  color: var(--accent-green);
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

/* Double Tap Red Heart Animation */
.floating-heart {
  position: absolute;
  pointer-events: none;
  color: var(--accent-red);
  filter: drop-shadow(0 6px 18px rgba(254, 44, 85, 0.5));
  z-index: 40;
  animation: heartPop 0.75s cubic-bezier(0.17, 0.89, 0.32, 1.49) forwards;
}

@keyframes heartPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3) rotate(var(--rot, -10deg)); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(var(--scale, 1.2)) rotate(var(--rot, -10deg)); }
  75% { opacity: 1; transform: translate(-50%, -65%) scale(var(--scale, 1.2)) rotate(var(--rot, -10deg)); }
  100% { opacity: 0; transform: translate(-50%, -95%) scale(calc(var(--scale, 1.2) * 1.15)) rotate(var(--rot, -10deg)); }
}

/* Left Action Rail (TikTok Style) */
.action-rail {
  position: absolute;
  left: 12px;
  bottom: 26px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.rail-avatar-box {
  position: relative;
  width: 48px;
  height: 48px;
  margin-bottom: 6px;
}

.rail-avatar-box img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #ffffff;
  background: var(--bg-navy);
  cursor: pointer;
}

.rail-follow-badge {
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-red);
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.rail-btn {
  background: none;
  border: none;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.rail-btn svg {
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6));
  transition: transform 0.15s;
}

.rail-btn:active svg {
  transform: scale(0.85);
}

.rail-btn.liked svg {
  fill: var(--accent-red);
  color: var(--accent-red);
}

.rail-btn.bookmarked svg {
  fill: var(--accent-green);
  color: var(--accent-green);
}

.rail-btn span {
  font-size: 12px;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

/* Bottom Right Creator & Caption Info */
.video-meta {
  position: absolute;
  right: 14px;
  left: 74px;
  bottom: 22px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meta-author {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.verified-dot {
  color: var(--accent-green);
  width: 15px;
  height: 15px;
}

.meta-caption {
  font-size: 13.5px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.92);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta-caption.expanded {
  -webkit-line-clamp: unset;
}

.hashtag-link {
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

/* Scrubber Progress Bar */
.video-scrubber {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 12px;
  z-index: 25;
  display: flex;
  align-items: flex-end;
  cursor: pointer;
}

.scrubber-track {
  width: 100%;
  height: 2.5px;
  background: rgba(255, 255, 255, 0.25);
  transition: height 0.15s;
}

.video-scrubber:hover .scrubber-track,
.video-scrubber.dragging .scrubber-track {
  height: 6px;
}

.scrubber-fill {
  height: 100%;
  width: 0%;
  background: #ffffff;
}

/* Bottom Navigation Bar */
.bottom-nav {
  height: 58px;
  background: #000000;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 50;
}

.nav-item {
  position: relative;
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  width: 56px;
}

.nav-item svg {
  width: 22px;
  height: 22px;
}

.nav-item.active {
  color: #ffffff;
}

.nav-badge {
  position: absolute;
  top: -2px;
  right: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-red);
}

/* TikTok Iconic + Button with Reelfy Emerald Green */
.nav-create-btn {
  position: relative;
  width: 44px;
  height: 28px;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.create-layer-left,
.create-layer-right {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 36px;
  border-radius: 8px;
}

.create-layer-left {
  left: 0;
  background: var(--accent-green);
}

.create-layer-right {
  right: 0;
  background: var(--accent-red);
}

.create-layer-center {
  position: relative;
  width: 36px;
  height: 28px;
  border-radius: 8px;
  background: #ffffff;
  color: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.create-layer-center svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.8;
}

/* Subpages, Grids & Buttons */
.subpage-header {
  height: 54px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-black);
}

.subpage-header.center-title {
  justify-content: center;
}

.subpage-header.space-between {
  justify-content: space-between;
}

.subpage-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.icon-btn-ghost {
  background: none;
  border: none;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}

.video-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5px;
  align-content: start;
}

.grid-item {
  position: relative;
  aspect-ratio: 9 / 14;
  background: var(--bg-navy);
  cursor: pointer;
  overflow: hidden;
}

.grid-item img,
.grid-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.grid-views {
  position: absolute;
  bottom: 6px;
  right: 6px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 3px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
}

.empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 14px;
}

.toast {
  position: fixed;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-navy);
  border: 1px solid var(--accent-green);
  color: #ffffff;
  padding: 9px 18px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  z-index: 9999;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.7);
}
