/* =========================================================
   VibeTok — style.css
   Palette: void #0B0B10, ink #16161D, mist #C9C9D6,
            vibe-1 #FF3D77 (rose), vibe-2 #7C4DFF (violet),
            vibe-3 #FFB020 (amber accent)
   Type: Poppins (display/brand), Inter (UI/body)
   ========================================================= */

:root {
  --void: #0b0b10;
  --ink: #16161d;
  --ink-2: #1e1e28;
  --mist: #c9c9d6;
  --mist-dim: #8d8d9c;
  --white: #f7f7fb;
  --vibe-1: #ff3d77;
  --vibe-2: #7c4dff;
  --vibe-3: #ffb020;
  --gradient-vibe: linear-gradient(135deg, var(--vibe-1), var(--vibe-2));
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.14);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --nav-h: 58px;
  --shadow-pop: 0 10px 40px rgba(0, 0, 0, 0.45);
  --font-display: "Poppins", "Inter", sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--void);
  color: var(--white);
  font-family: var(--font-body);
  overflow-x: hidden;
}

.hidden { display: none !important; }

a { color: inherit; }

button {
  font-family: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--vibe-3);
  outline-offset: 2px;
}

/* ---------- Top bar ---------- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: linear-gradient(to bottom, rgba(11, 11, 16, 0.85), rgba(11, 11, 16, 0));
  backdrop-filter: blur(6px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--gradient-vibe);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 0 22px rgba(255, 61, 119, 0.55);
  flex-shrink: 0;
}

.brand-mark-sm {
  width: 28px;
  height: 28px;
  font-size: 14px;
  border-radius: 8px;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.01em;
}

.topbar-tabs {
  display: flex;
  align-items: center;
  gap: 22px;
  flex: 1;
  justify-content: center;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--mist-dim);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  padding: 4px 0;
  position: relative;
  transition: color 0.15s ease;
}
.tab-btn.active {
  color: var(--white);
}
.tab-btn.active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  width: 22px;
  height: 3px;
  border-radius: 999px;
  background: var(--gradient-vibe);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--white);
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.96); }

.btn-primary {
  background: var(--gradient-vibe);
  color: var(--white);
}
.btn-primary:hover { opacity: 0.92; }

.btn-ghost {
  background: var(--glass-bg);
  color: var(--white);
  border: 1px solid var(--glass-border);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.14); }

.btn-google {
  background: var(--white);
  color: #1f1f1f;
  justify-content: center;
}

.btn-full { width: 100%; justify-content: center; }
.btn-small { padding: 7px 12px; font-size: 13px; }

.btn-label { display: inline; }

.auth-area { display: flex; align-items: center; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 5px 6px 5px 5px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gradient-vibe);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
}

.user-name-label {
  font-size: 13px;
  font-weight: 600;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Feed ---------- */
.feed {
  height: 100vh;
  height: 100dvh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  position: relative;
}

.feed-loading {
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid var(--glass-border);
  border-top-color: var(--vibe-1);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.feed-empty {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 30px;
  scroll-snap-align: start;
}
.feed-empty-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 6px;
}
.feed-empty-sub {
  color: var(--mist-dim);
  margin: 0;
  font-size: 14px;
}

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

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

.video-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0.05) 35%, rgba(0, 0, 0, 0.35) 100%);
  pointer-events: none;
}

.video-info {
  position: absolute;
  left: 16px;
  right: 84px;
  bottom: calc(var(--nav-h) + 26px);
  z-index: 2;
}

.video-username {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  margin: 0 0 6px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

.video-caption {
  font-size: 14px;
  line-height: 1.4;
  margin: 0;
  color: var(--mist);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
  word-break: break-word;
}

/* ---------- Mute toggle (floating) ---------- */
.mute-toggle {
  position: absolute;
  top: 64px;
  right: 14px;
  z-index: 3;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
  color: var(--white);
  display: grid;
  place-items: center;
}
.mute-toggle:active { transform: scale(0.9); }

/* ---------- Video progress bar ---------- */
.video-progress-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--nav-h);
  height: 3px;
  background: rgba(255, 255, 255, 0.18);
  z-index: 3;
}
.video-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--gradient-vibe);
}

/* ---------- Action rail ---------- */
.action-rail {
  position: absolute;
  right: 12px;
  bottom: calc(var(--nav-h) + 26px);
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.rail-avatar-wrap {
  position: relative;
  margin-bottom: 4px;
}

.rail-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--gradient-vibe);
  border: 2px solid var(--white);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  text-transform: uppercase;
}

.rail-follow-btn {
  position: absolute;
  left: 50%;
  bottom: -9px;
  transform: translateX(-50%);
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--vibe-1);
  border: 2px solid var(--ink);
  color: var(--white);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  display: grid;
  place-items: center;
}
.rail-follow-btn:active { transform: translateX(-50%) scale(0.85); }
.rail-follow-btn.following {
  background: var(--mist-dim);
  font-size: 11px;
}

.rail-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
  color: var(--white);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: transform 0.15s ease, background 0.15s ease;
}
.rail-btn:active { transform: scale(0.9); }

.rail-count {
  font-size: 10px;
  font-weight: 600;
  color: var(--mist);
}

.like-btn.liked {
  color: var(--vibe-1);
}
.like-btn.liked .icon-heart {
  animation: pop 0.35s ease;
}
.save-btn.saved {
  color: var(--vibe-3);
}
.save-btn.saved .icon-bookmark {
  animation: pop 0.35s ease;
}
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(6, 6, 10, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--ink);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 28px 24px 24px;
  box-shadow: var(--shadow-pop);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: var(--mist-dim);
  font-size: 24px;
  line-height: 1;
  padding: 4px;
}
.modal-close:hover { color: var(--white); }

.modal-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  margin: 0 0 20px;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--mist-dim);
  margin: 14px 0 6px;
}

.field-input {
  width: 100%;
  background: var(--ink-2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  color: var(--white);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
.field-input:focus { border-color: var(--vibe-2); }
.field-input::placeholder { color: var(--mist-dim); }

.field-error {
  color: var(--vibe-1);
  font-size: 13px;
  margin: 10px 0 0;
}

.auth-form { display: flex; flex-direction: column; }
.auth-form .btn { margin-top: 20px; }

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
  color: var(--mist-dim);
  font-size: 12px;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--glass-border);
}

.auth-switch {
  text-align: center;
  font-size: 13px;
  color: var(--mist-dim);
  margin: 18px 0 0;
}

.link-btn {
  background: none;
  border: none;
  color: var(--vibe-2);
  font-weight: 600;
  font-size: 13px;
  padding: 0;
  margin-left: 4px;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- Upload ---------- */
.upload-form { display: flex; flex-direction: column; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px 12px;
  border: 1.5px dashed var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--mist-dim);
  text-align: center;
  font-size: 13px;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.dropzone:hover, .dropzone.file-chosen {
  border-color: var(--vibe-2);
  color: var(--white);
}

.upload-progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.upload-progress-track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--ink-2);
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--gradient-vibe);
  transition: width 0.2s ease;
}

.upload-progress-label {
  font-size: 12px;
  color: var(--mist-dim);
  min-width: 34px;
  text-align: right;
}

.upload-form .btn { margin-top: 20px; }

/* ---------- Comments panel ---------- */
.comments-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 90;
  width: 100%;
  max-width: 380px;
  background: var(--ink);
  border-left: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.4);
}

.comments-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--glass-border);
}
.comments-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
}
.comments-header .modal-close { position: static; }

.comments-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.comment-item { display: flex; flex-direction: column; gap: 2px; }
.comment-author {
  font-size: 13px;
  font-weight: 700;
  color: var(--vibe-2);
}
.comment-text { font-size: 13.5px; color: var(--mist); line-height: 1.4; }
.comment-empty { color: var(--mist-dim); font-size: 13px; text-align: center; margin-top: 30px; }

.comment-form {
  display: flex;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--glass-border);
}
.comment-form .field-input { flex: 1; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink-2);
  border: 1px solid var(--glass-border);
  color: var(--white);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 200;
  box-shadow: var(--shadow-pop);
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: rgba(11, 11, 16, 0.88);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--glass-border);
}

.nav-btn {
  background: none;
  border: none;
  color: var(--mist-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  font-weight: 600;
  padding: 4px 8px;
}
.nav-btn.active { color: var(--white); }
.nav-btn:active { transform: scale(0.92); }

.nav-upload {
  background: var(--gradient-vibe);
  border: none;
  color: var(--white);
  width: 46px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  box-shadow: 0 0 18px rgba(255, 61, 119, 0.5);
}
.nav-upload:active { transform: scale(0.92); }

.nav-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gradient-vibe);
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--white);
  text-transform: uppercase;
}

/* ---------- Profile panel ---------- */
.profile-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  padding: 6px 0 18px;
}

.profile-avatar-lg {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--gradient-vibe);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 28px;
  text-transform: uppercase;
}

.profile-avatar-wrap {
  position: relative;
  margin-bottom: 10px;
}

.edit-avatar-btn {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--gradient-vibe);
  border: 2px solid var(--ink);
  color: var(--white);
  display: grid;
  place-items: center;
}
.edit-avatar-btn:active { transform: scale(0.9); }

.profile-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  margin: 0;
}

.profile-email {
  font-size: 13px;
  color: var(--mist-dim);
  margin: 0 0 8px;
  word-break: break-all;
}

.profile-stats {
  font-size: 13px;
  color: var(--mist);
  margin: 0 0 16px;
}
.profile-stats span:not(.profile-stats-dot) {
  font-weight: 700;
  color: var(--white);
}
.profile-stats-dot {
  margin: 0 6px;
  color: var(--mist-dim);
}

.profile-view .btn { width: 100%; max-width: 220px; }

.profile-footer-credit {
  text-align: center;
  font-size: 12px;
  color: var(--mist-dim);
  padding-top: 16px;
  border-top: 1px solid var(--glass-border);
}
.profile-footer-credit a {
  color: var(--vibe-3);
  font-weight: 600;
  text-decoration: none;
}
.profile-footer-credit a:hover { text-decoration: underline; }

/* ---------- Responsive ---------- */
@media (min-width: 640px) {
  .video-card { max-width: 480px; margin: 0 auto; }
  .action-rail { right: calc(50% - 240px + 12px); }
  .video-info { right: calc(50% - 240px + 84px); left: calc(50% - 240px + 16px); }
  .video-progress-track { max-width: 480px; margin: 0 auto; }
}

@media (max-width: 420px) {
  .btn-label { display: none; }
  .brand-name { font-size: 17px; }
  .topbar-tabs { gap: 16px; }
  .tab-btn { font-size: 14px; }
  .nav-btn span { font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
