:root {
  --bottom-nav-h: 56px;
}

body.has-bottom-nav {
  padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
}

body.has-bottom-nav main {
  padding-bottom: 0;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: var(--toolbar-bg);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  transition: background var(--transition), border-color var(--transition);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--bottom-nav-h);
  padding: 0.35rem 0.25rem;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: capitalize;
  transition: color var(--transition), transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item svg {
  width: 26px;
  height: 26px;
  stroke-width: 1.75;
  transition: stroke var(--transition), fill var(--transition), transform 0.15s ease;
}

.bottom-nav-item:hover {
  color: var(--text-secondary);
}

.bottom-nav-item.active {
  color: var(--primary);
}

.bottom-nav-item.active svg {
  stroke: var(--primary);
}

.bottom-nav-item--reels {
  position: relative;
}

.bottom-nav-item--reels svg {
  width: 28px;
  height: 28px;
}

.bottom-nav-item--reels.active svg {
  filter: drop-shadow(0 0 6px rgba(249, 115, 22, 0.45));
}

/* Tab panels */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.tab-panel--reels.active {
  display: block;
  position: fixed;
  top: calc(var(--toolbar-h) + var(--pwa-install-bar-h, 0px));
  left: 0;
  right: 0;
  bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  z-index: 10;
  background: #000;
}

body.tab-reels .site-footer {
  display: none;
}

body.tab-reels .hero,
body.tab-reels .stories-section {
  display: none;
}

/* Reels */
.reels-viewport {
  height: 100%;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.reels-viewport::-webkit-scrollbar {
  display: none;
}

.reel-slide {
  position: relative;
  height: 100%;
  min-height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reel-slide video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #111;
}

.reel-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.75) 0%,
    transparent 35%,
    transparent 70%,
    rgba(0, 0, 0, 0.25) 100%
  );
}

.reel-meta {
  position: absolute;
  left: 0;
  right: 4rem;
  bottom: 1rem;
  padding: 0 1rem;
  color: #fff;
  pointer-events: none;
  z-index: 2;
}

.reel-meta-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.reel-meta-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
}

.reel-meta strong {
  font-size: 0.9rem;
}

.reel-caption {
  font-size: 0.85rem;
  line-height: 1.45;
  opacity: 0.95;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.reel-actions {
  position: absolute;
  right: 0.75rem;
  bottom: 5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  z-index: 3;
}

.reel-action-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s, transform 0.15s;
  pointer-events: auto;
}

.reel-action-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.reel-action-btn:active {
  transform: scale(0.92);
}

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

.reels-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  color: rgba(255, 255, 255, 0.7);
}

.reels-empty h3 {
  color: #fff;
  font-family: var(--font-display);
  margin: 1rem 0 0.5rem;
}

.reels-empty .btn {
  margin-top: 1.25rem;
}

/* Explore tab */
.explore-tab-header {
  padding: 1rem 0 0.75rem;
}

.explore-tab-header h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.explore-search {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 1rem;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: 0.875rem;
}

.explore-search svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

.profile-hero {
  text-align: center;
  padding: 2rem 1rem 1.5rem;
}

.profile-avatar-lg {
  width: 88px;
  height: 88px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--orange-400), var(--orange-700));
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.75rem;
  color: #fff;
  box-shadow: 0 8px 24px rgba(249, 115, 22, 0.35);
}

.profile-hero h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin-bottom: 0.25rem;
}

.profile-hero p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.profile-stats {
  display: flex;
  justify-content: center;
  gap: 2.5rem;
  margin: 1.5rem 0;
  padding: 1rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.profile-stats .stat strong {
  font-size: 1.25rem;
}

@media (min-width: 768px) {
  .bottom-nav {
    max-width: 430px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }

  .tab-panel--reels.active {
    max-width: 430px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}
