:root {
  --bg: #050508;
  --surface: #12121a;
  --surface-elevated: #1b1b26;
  --cyan: #00f2ea;
  --coral: #ff3366;
  --violet: #7c3aed;
  --text: #ffffff;
  --muted: #9ea0b3;
  --nav-height: 62px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

.hidden { display: none !important; }

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* Auth Screen */
#auth-screen {
  justify-content: center;
  align-items: center;
  padding: 24px;
  background: radial-gradient(circle at top, rgba(124, 58, 237, 0.28), var(--bg) 60%);
}

.auth-card {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 24px;
  padding: 28px 22px;
  text-align: center;
}

.brand-badge {
  width: 58px;
  height: 58px;
  margin: 0 auto 12px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 22px;
  background: linear-gradient(135deg, var(--cyan), var(--violet), var(--coral));
  color: #050508;
}

.auth-card h1 { margin: 0 0 6px; font-size: 26px; }
.subtitle { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 14px;
}

.auth-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 9px;
  border-radius: 9px;
  font-weight: 600;
  cursor: pointer;
}

.auth-tab.active {
  background: var(--surface-elevated);
  color: var(--text);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  outline: none;
}

.input:focus { border-color: var(--cyan); }

.btn-primary {
  border: none;
  border-radius: 12px;
  padding: 13px 16px;
  background: linear-gradient(90deg, var(--coral), #ff5c8a);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}

.btn-primary.small { padding: 10px 14px; font-size: 14px; }

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  color: var(--muted);
  font-size: 12px;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.1);
}

.btn-google {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.16);
  background: var(--surface-elevated);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.g-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  color: #111;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
}

.auth-error {
  margin: 12px 0 0;
  color: #ff7b98;
  font-size: 13px;
}

/* iOS Install Banner */
.ios-banner {
  background: rgba(0, 242, 234, 0.14);
  border-bottom: 1px solid rgba(0, 242, 234, 0.3);
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 14px 8px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  z-index: 30;
}
.ios-banner button {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

/* Main Tab Views */
.tab-view {
  flex: 1;
  position: relative;
  overflow-y: auto;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
}

#view-feed { overflow: hidden; padding-bottom: 0; }

.feed-header {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 20;
  pointer-events: none;
}

.feed-header > * { pointer-events: auto; }

.feed-tabs { display: flex; gap: 18px; }
.feed-tab {
  background: none;
  border: none;
  color: rgba(255,255,255,0.65);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  padding-bottom: 4px;
}
.feed-tab.active {
  color: #fff;
  border-bottom: 2px solid var(--cyan);
}

.pill-btn {
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(0,0,0,0.48);
  color: #fff;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

/* Vertical Reels Scroller */
.feed-scroller {
  height: calc(100% - var(--nav-height) - env(safe-area-inset-bottom, 0px));
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
}

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

.reel-card {
  position: relative;
  width: 100%;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: #000;
  overflow: hidden;
}

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

.reel-scrim {
  position: absolute;
  inset: auto 0 0 0;
  height: 45%;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  pointer-events: none;
}

.reel-meta {
  position: absolute;
  left: 16px;
  right: 76px;
  bottom: 20px;
  z-index: 10;
}

.reel-handle {
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.verified-dot {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #0095f6;
  color: #fff;
  font-size: 10px;
}

.reel-caption {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.35;
  color: rgba(255,255,255,0.94);
}

.reel-sound {
  display: inline-block;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.18);
  font-size: 12px;
  color: var(--cyan);
}

.reel-actions {
  position: absolute;
  right: 12px;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 10;
}

.action-btn {
  background: none;
  border: none;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  cursor: pointer;
}
.action-btn span.icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  display: grid;
  place-items: center;
  font-size: 20px;
}
.action-btn.liked span.icon { color: var(--coral); }

/* Discover & Profile */
.page-header {
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 16px 12px;
}
.page-header h2 { margin: 0 0 12px; font-size: 22px; }
.profile-top { display: flex; justify-content: space-between; align-items: center; }
.muted { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

.section-block { padding: 8px 16px 18px; }
.section-block h3 { margin: 0 0 10px; font-size: 16px; }

.sound-list { display: flex; flex-direction: column; gap: 8px; }
.sound-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.06);
}

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

.grid-card {
  background: var(--surface);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  padding: 12px;
  cursor: pointer;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 8px 16px;
}
.stat-box {
  background: var(--surface);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
}
.stat-box strong { display: block; font-size: 18px; color: var(--cyan); }
.stat-box span { font-size: 12px; color: var(--muted); }

.dashboard-card {
  margin: 12px 16px;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(0,242,234,0.12), rgba(124,58,237,0.16));
  border: 1px solid rgba(0,242,234,0.25);
}
.dashboard-card h3 { margin: 0; }
.dash-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.dash-metrics span { display: block; font-size: 12px; color: var(--muted); }
.dash-metrics strong { font-size: 17px; }

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(5,5,8,0.94);
  border-top: 1px solid rgba(255,255,255,0.08);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  z-index: 25;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  gap: 2px;
  cursor: pointer;
}
.nav-btn span { font-size: 11px; font-weight: 600; }
.nav-btn.active { color: var(--cyan); }

/* Comments Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: flex-end;
  z-index: 40;
}
.modal-sheet {
  width: 100%;
  max-height: 75vh;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { margin: 0; }
.comments-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.comment-item { background: var(--bg); padding: 10px 12px; border-radius: 12px; font-size: 14px; }
.comment-form { display: flex; gap: 8px; }

.loading-state {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 18px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-elevated);
  border: 1px solid var(--cyan);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 50;
}
