* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #000;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior-y: none;
}

/* ---------- Feed page ---------- */

#feed {
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}
#feed::-webkit-scrollbar { display: none; }

.video-card {
  position: relative;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #111;
}

.video-card video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.mute-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.25s ease;
  z-index: 5;
}
.mute-indicator.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.08);
}
.mute-indicator svg { width: 34px; height: 34px; fill: #fff; }

.heart-burst {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 120px;
  height: 120px;
  opacity: 0;
  pointer-events: none;
  z-index: 6;
}
.heart-burst svg {
  width: 100%;
  height: 100%;
  fill: #fe2c55;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.4));
}
.heart-burst.show {
  animation: heart-burst-pop 0.7s ease forwards;
}
@keyframes heart-burst-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  30% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.05); }
}

.video-gradient-top, .video-gradient-bottom {
  position: absolute;
  left: 0; right: 0;
  pointer-events: none;
  z-index: 2;
}
.video-gradient-top {
  top: 0; height: 90px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.35), transparent);
}
.video-gradient-bottom {
  bottom: 0; height: 220px;
  background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
}

.video-info {
  position: absolute;
  left: 14px;
  right: 92px;
  bottom: calc(90px + var(--rail-inset, 0px));
  z-index: 3;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}
.video-info .creator {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 6px;
  display: block;
}
.video-info .caption {
  font-size: 14px;
  line-height: 1.35;
  font-weight: 400;
  word-wrap: break-word;
}
.video-info .category-tag {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(4px);
}

/* Right-hand action rail */
.action-rail {
  position: absolute;
  right: 10px;
  bottom: calc(23px + var(--rail-inset, 0px));
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 13px;
}
.action-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.action-item .icon-circle {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.action-item svg {
  width: 32px;
  height: 32px;
  fill: #fff;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
  transition: transform 0.15s ease;
}
.action-item.pressed svg { transform: scale(1.18); }

.action-item.like.liked svg { fill: #fe2c55; }
.action-item.save.saved svg { fill: #ffd43b; }

.profile-circle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6a5cff, #ff5c8a);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  border: 2px solid #fff;
  margin-bottom: 2px;
}

/* Home/mute/profile buttons, clustered together and centered at the
   bottom of the feed so they stay clear of the right-hand action rail. */
.fab-row {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
}
.home-fab, .mute-fab, .profile-fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(30,30,30,0.75);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
.home-fab svg, .mute-fab svg, .profile-fab svg { width: 24px; height: 24px; fill: #fff; }

.top-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  padding: 14px 0 8px;
  pointer-events: none;
}
.top-bar span {
  font-weight: 700;
  font-size: 16px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  padding-bottom: 6px;
  border-bottom: 2px solid #fff;
}

.empty-state, .loading-state {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
  gap: 10px;
}
.empty-state h2 { margin: 0; font-size: 20px; }
.empty-state p { margin: 0; color: #aaa; font-size: 14px; max-width: 320px; }
.empty-state code {
  background: #1c1c1c;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  color: #ff9fbb;
  word-break: break-all;
}

/* ---------- Comments sheet ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.comments-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 31;
  background: #161616;
  border-radius: 16px 16px 0 0;
  max-height: 70vh;
  height: 70vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.25s ease;
  color: #fff;
}
.comments-sheet.open { transform: translateY(0); }

.comments-header {
  text-align: center;
  padding: 14px 16px 10px;
  font-weight: 700;
  font-size: 15px;
  border-bottom: 1px solid #2a2a2a;
  position: relative;
}
.comments-header .close-btn {
  position: absolute;
  right: 12px;
  top: 10px;
  background: none;
  border: none;
  color: #999;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.comments-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
}
.comment-row {
  display: flex;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid #232323;
}
.comment-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(135deg, #6a5cff, #ff5c8a);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.comment-body { flex: 1; min-width: 0; }
.comment-user {
  font-size: 12px;
  color: #a6a6a6;
  margin-bottom: 3px;
}
.comment-text {
  font-size: 14px;
  line-height: 1.35;
  word-wrap: break-word;
}
.comment-meta {
  display: flex;
  gap: 14px;
  margin-top: 6px;
  font-size: 11px;
  color: #888;
}
.comment-like {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  padding: 0;
}
.comment-like svg { width: 14px; height: 14px; fill: #888; }
.comment-like.liked svg { fill: #fe2c55; }
.comment-like.liked { color: #fe2c55; }

.comments-empty {
  color: #888;
  text-align: center;
  padding: 30px 10px;
  font-size: 13px;
}

.comment-composer {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid #2a2a2a;
  background: #161616;
}
.comment-composer input {
  flex: 1;
  background: #262626;
  border: none;
  border-radius: 20px;
  padding: 10px 14px;
  color: #fff;
  font-size: 14px;
  outline: none;
}
.comment-composer button {
  background: none;
  border: none;
  color: #4da6ff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  padding: 6px 4px;
}
.comment-composer button:disabled { color: #444; cursor: default; }

/* ---------- Share sheet ---------- */

.share-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 31;
  background: #161616;
  border-radius: 16px 16px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.25s ease;
  color: #fff;
}
.share-sheet.open { transform: translateY(0); }
.share-sheet h3 {
  margin: 0 0 14px;
  font-size: 15px;
  text-align: center;
}
.share-link-row {
  display: flex;
  gap: 8px;
}
.share-link-row input {
  flex: 1;
  background: #262626;
  border: none;
  border-radius: 10px;
  padding: 12px;
  color: #ccc;
  font-size: 12px;
  outline: none;
}
.share-copy-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fe2c55;
  border: none;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  border-radius: 10px;
  padding: 0 16px;
  cursor: pointer;
}
.share-copy-btn svg { width: 16px; height: 16px; fill: #fff; }

/* ---------- Save-to-collection sheet ---------- */

.save-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 31;
  background: #161616;
  border-radius: 16px 16px 0 0;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.25s ease;
  color: #fff;
}
.save-sheet.open { transform: translateY(0); }

.save-sheet-header {
  text-align: center;
  padding: 14px 16px 10px;
  font-weight: 700;
  font-size: 15px;
  border-bottom: 1px solid #2a2a2a;
  position: relative;
}
.save-sheet-header .close-btn {
  position: absolute;
  right: 12px;
  top: 10px;
  background: none;
  border: none;
  color: #999;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.collections-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
  min-height: 60px;
}
.collection-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #232323;
  cursor: pointer;
}
.collection-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: #fe2c55;
  flex-shrink: 0;
}
.collection-row .collection-name {
  flex: 1;
  font-size: 14px;
}
.collection-row .collection-count {
  font-size: 12px;
  color: #888;
}
.collections-empty {
  color: #888;
  text-align: center;
  padding: 20px 10px;
  font-size: 13px;
}

.new-collection-form {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid #2a2a2a;
  background: #161616;
}
.new-collection-form input {
  flex: 1;
  background: #262626;
  border: none;
  border-radius: 20px;
  padding: 10px 14px;
  color: #fff;
  font-size: 14px;
  outline: none;
}
.new-collection-form button {
  background: #fe2c55;
  border: none;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  border-radius: 20px;
  padding: 8px 16px;
  cursor: pointer;
}

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20,20,20,0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

/* ---------- Home page ---------- */

.home-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  background: #0b0b0b;
  padding-bottom: 100px;
}
.home-header {
  padding: 22px 18px 10px;
  position: sticky;
  top: 0;
  background: #0b0b0b;
  z-index: 5;
}
.home-header h1 {
  margin: 0;
  font-size: 22px;
}
.home-header p {
  margin: 4px 0 0;
  color: #999;
  font-size: 13px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding: 16px;
}
@media (min-width: 560px) {
  .category-grid { grid-template-columns: repeat(3, 1fr); }
}

.category-tile {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  padding: 14px;
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  background-color: #333;
  background-size: cover;
  background-position: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}
.categories-empty {
  grid-column: 1 / -1;
  color: #888;
  text-align: center;
  padding: 40px 16px;
  font-size: 14px;
}
.category-tile .tile-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.55), rgba(0,0,0,0) 55%);
}
.category-tile span.label {
  position: relative;
  z-index: 1;
}

.home-fab.active {
  background: rgba(254,44,85,0.9);
  border-color: transparent;
}

/* ---------- Profile page ---------- */

.profile-collections {
  padding: 4px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.profile-collection-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #1c1c1e;
  text-decoration: none;
  color: #fff;
}
.profile-collection-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.profile-collection-icon svg { width: 22px; height: 22px; fill: #fff; }
.profile-collection-info { flex: 1; min-width: 0; }
.profile-collection-name {
  font-weight: 700;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-collection-count {
  font-size: 13px;
  color: #777;
  margin-top: 2px;
}
.profile-collections-empty {
  color: #888;
  text-align: center;
  padding: 40px 16px;
  font-size: 14px;
}

/* Bottom section-nav bar, home/profile pages only */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  gap: 48px;
  padding: 10px 0 max(10px, env(safe-area-inset-bottom));
  background: #161616;
  border-top: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.3);
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  color: #888;
  font-size: 11px;
  font-weight: 600;
}
.nav-item svg { width: 26px; height: 26px; fill: currentColor; }
.nav-item.active { color: #fff; }
.nav-item .nav-icon-play { width: 34px; height: 24px; fill: #fff; }

/* ---------- Settings ---------- */

.settings-fab {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 20;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(30,30,30,0.75);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
.settings-fab svg { width: 22px; height: 22px; fill: #fff; }

.settings-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 31;
  background: #161616;
  border-radius: 16px 16px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.25s ease;
  color: #fff;
}
.settings-sheet.open { transform: translateY(0); }
.settings-sheet h3 {
  margin: 0 0 10px;
  font-size: 15px;
  text-align: center;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 4px;
}
.settings-row .settings-label {
  font-size: 15px;
  font-weight: 600;
}
.settings-row .settings-desc {
  font-size: 12px;
  color: #999;
  margin-top: 2px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-switch .toggle-track {
  position: absolute;
  inset: 0;
  background: #3a3a3a;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.toggle-switch .toggle-track::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}
.toggle-switch input:checked + .toggle-track {
  background: #fe2c55;
}
.toggle-switch input:checked + .toggle-track::before {
  transform: translateX(20px);
}

/* ---------- Light theme (Browse / Profile pages; off = dark mode) ---------- */
/* Default (no class) is dark -- also what the feed/video-player page always
   uses, since the Dark Mode setting never touches it. Browse and Profile
   get this class added/removed by their own JS based on the stored
   preference, defaulting to light (this class present) until the user
   turns Dark Mode on. */

body.light-theme {
  background: #fff;
  color: #1a1a1a;
}
body.light-theme .home-wrap {
  background: #fff;
}
body.light-theme .home-header {
  background: #fff;
}
body.light-theme .home-header p {
  color: #666;
}
body.light-theme .settings-fab {
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(0,0,0,0.1);
  color: #1a1a1a;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}
body.light-theme .settings-fab svg { fill: #1a1a1a; }
body.light-theme .settings-sheet {
  background: #fff;
  color: #1a1a1a;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
}
body.light-theme .settings-row .settings-desc {
  color: #777;
}
body.light-theme .toggle-switch .toggle-track {
  background: #d6d6d9;
}
body.light-theme .sheet-backdrop {
  background: rgba(0,0,0,0.35);
}
body.light-theme .bottom-nav {
  background: #fff;
  border-top: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}
body.light-theme .nav-item { color: #999; }
body.light-theme .nav-item.active { color: #1a1a1a; }
body.light-theme .nav-item .nav-icon-play { fill: #000; }
body.light-theme .profile-collection-card {
  background: #f4f4f5;
  color: #1a1a1a;
}
