* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: #000;
  color: #fff;
  overflow: hidden;
}

/* SPLASH */
#splash {
  position: fixed;
  inset: 0;
  background: #0B0F1A;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  animation: fadeOut 2.5s ease forwards;
  animation-delay: 2s;
}

#splash .logo {
  font-size: 36px;
  font-weight: bold;
  background: linear-gradient(90deg, #3B82F6, #8B5CF6, #22D3EE);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#splash p {
  opacity: 0.7;
  margin-top: 12px;
  font-size: 14px;
}

/* APP SHELL */
#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* TOP BAR */
.topbar {
  height: 50px;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 100;
}

.brand {
  font-weight: 600;
  font-size: 16px;
  background: linear-gradient(90deg, #3B82F6, #8B5CF6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.topbar button {
  padding: 8px 16px;
  background: rgba(250, 204, 21, 0.2);
  color: #facc15;
  border: 1px solid rgba(250, 204, 21, 0.5);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.topbar button:active {
  background: rgba(250, 204, 21, 0.3);
  transform: scale(0.95);
}

/* DEBUG PANEL */
#debugPanel {
  white-space: pre-wrap;
  background: rgba(127, 29, 29, 0.9);
  backdrop-filter: blur(10px);
  color: #fff;
  padding: 12px;
  font: 12px monospace;
  max-height: 160px;
  overflow: auto;
  z-index: 9001;
}

/* VIEWS */
.view {
  flex: 1;
  overflow: hidden;
}

.view-header {
  padding: 14px 16px 10px;
}

.view-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.subtle {
  margin: 6px 0 0;
  font-size: 13px;
  opacity: 0.75;
}

.section {
  padding: 10px 16px 16px;
}

.section h3 {
  margin: 0 0 10px;
  font-size: 13px;
  opacity: 0.85;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 13px;
  font-weight: 600;
}

.empty-hint {
  margin-top: 10px;
  font-size: 13px;
  opacity: 0.7;
}

.cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mini-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.mini-card .avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: radial-gradient(circle at 30% 30%, rgba(59, 130, 246, 0.7), rgba(34, 211, 238, 0.15) 60%), rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.mini-meta {
  flex: 1;
}

.mini-title {
  font-weight: 800;
  font-size: 14px;
}

.mini-sub {
  opacity: 0.7;
  font-size: 13px;
  margin-top: 4px;
}

.mini-cta {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(250, 204, 21, 0.4);
  background: rgba(250, 204, 21, 0.14);
  color: #facc15;
  font-weight: 800;
  cursor: pointer;
}

.list-item {
  padding: 12px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 10px;
  font-size: 14px;
  opacity: 0.9;
}

/* PROFILE */
.profile-hero {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px 16px 10px;
}

.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: radial-gradient(circle at 30% 30%, rgba(59, 130, 246, 0.7), rgba(139, 92, 246, 0.2) 55%, rgba(34, 211, 238, 0.12)), rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.profile-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-username {
  font-size: 18px;
  font-weight: 900;
}

.profile-handle {
  font-size: 13px;
  opacity: 0.75;
}

.profile-stats {
  display: flex;
  gap: 10px;
  padding: 8px 16px 0;
}

.stat {
  flex: 1;
  padding: 12px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-num {
  font-weight: 900;
  font-size: 16px;
}

.stat-label {
  font-size: 12px;
  opacity: 0.75;
  margin-top: 4px;
}

.profile-bio {
  padding: 14px 16px;
  opacity: 0.85;
  font-size: 14px;
}

.profile-bio p {
  margin: 0;
  line-height: 1.4;
}

/* FEED */
.feed {
  flex: 1;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: 55px;
}

@media (max-width: 768px) {
  .feed {
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }
}

/* VIDEO CARD */
.video-container {
  height: calc(100vh - 105px);

  scroll-snap-align: start;
  scroll-snap-stop: always;
  position: relative;
  background: #000;
  display: flex;
}

.video-container iframe,
.video-container video {
  width: 100%;
  height: 100%;
  border: none;
  flex: 1;
  object-fit: contain;
  background: #000;
}

/* OVERLAY - TikTok/Reels bottom-left details */
.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 16px 92px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 35%, rgba(0, 0, 0, 0.78) 100%);
}

.overlay h1 {
  font-size: 17px;
  font-weight: 650;
  margin: 0 0 6px 0;
  line-height: 1.25;
  color: #fff;
  text-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
}

.overlay p {
  font-size: 13px;
  opacity: 0.85;
  margin: 0;
  color: #d1d5db;
}

/* ACTIONS - Floating round Tip button */
.actions {
  position: absolute;
  right: 14px;
  bottom: 118px;
  z-index: 20;
  pointer-events: auto;
}

.actions button {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  border: 1px solid rgba(250, 204, 21, 0.35);
  background: rgba(250, 204, 21, 0.95);
  color: #000;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.15s ease, filter 0.15s ease;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.actions button:active {
  transform: scale(0.96);
  filter: brightness(0.98);
}

/* BOTTOM NAV - Modern glass style */
.bottombar {
  height: 55px;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 0;
  padding: 0;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 500;
}

.nav-item {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  padding: 8px 0;
}

.nav-item:active {
  background: rgba(255, 255, 255, 0.1);
}

.nav-icon {
  font-size: 20px;
  line-height: 1;
}

.nav-label {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.8;
  letter-spacing: 0.3px;
}

/* CREATE BUTTON - Centered + icon */
.nav-create {
  flex: 1;
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s;
  color: #facc15;
  position: relative;
}

.nav-create:active {
  background: rgba(250, 204, 21, 0.1);
  transform: scale(0.95);
}

.create-icon {
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
}

/* Upload button is shared with Create; ensure it doesn't look like nav */
#uploadBtn {
  all: unset;
}

@media (max-width: 768px) {
  .bottombar {
    height: 60px;
    padding: 0 0 env(safe-area-inset-bottom, 0px) 0;
  }

  .nav-item {
    padding: 10px 0;
  }
}

/* MODAL */
.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  z-index: 10000;
  padding: 20px;
  -webkit-backdrop-filter: blur(5px);
}

.modal-backdrop.show {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 420px;
  background: rgba(17, 17, 17, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.modal-close {
  background: transparent;
  color: #fff;
  border: none;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.modal-close:hover {
  opacity: 1;
}

/* UPLOAD TABS */
.upload-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tab-btn {
  flex: 1;
  padding: 12px 0;
  background: transparent;
  border: none;
  color: #aaa;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.tab-btn.active {
  color: #facc15;
  border-bottom-color: #facc15;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.modal label {
  display: block;
  margin-top: 16px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #ddd;
}

.modal input[type="text"],
.modal input[type="url"],
.modal input[type="file"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s;
}

.modal input[type="text"]:focus,
.modal input[type="url"]:focus,
.modal input[type="file"]:focus {
  outline: none;
  border-color: rgba(250, 204, 21, 0.5);
  background: rgba(255, 255, 255, 0.08);
}

.modal input[type="file"] {
  padding: 10px;
  cursor: pointer;
}

.modal small {
  display: block;
  font-size: 11px;
  color: #888;
  margin-top: 6px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

.modal-actions button {
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.modal-actions button[type="submit"] {
  background: #facc15;
  color: #000;
  min-width: 100px;
}

.modal-actions button[type="submit"]:active {
  transform: scale(0.95);
}

.modal-actions button[type="button"] {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  min-width: 100px;
}

.modal-actions button[type="button"]:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* UPLOAD PROGRESS */
.upload-progress {
  margin-top: 16px;
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: #facc15;
  width: 0%;
  transition: width 0.3s;
}

#progressText {
  font-size: 12px;
  color: #aaa;
  margin: 0;
  text-align: center;
}

/* PROFILE GRID */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.grid-item {
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  aspect-ratio: 1 / 1;
  position: relative;
}

.grid-item button.grid-menu {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  z-index: 50;
  display: none;
}

.grid-item:hover button.grid-menu {
  display: flex;
  align-items: center;
  justify-content: center;
}

.grid-item button.grid-menu:active {
  transform: scale(0.96);
}

.grid-video {
  width: 100%;
  height: 100%;
  border: none;
  flex: 0;
}

.grid-thumb {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.03);
}

.grid-thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Improve thumbnail legibility behind the play icon */
.grid-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 35%, rgba(0, 0, 0, 0.55) 100%);
}

.grid-thumb > * {
  position: relative;
  z-index: 1;
}


.grid-thumb-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(250, 204, 21, 0.35);
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(250, 204, 21, 0.95);
  font-size: 18px;
  font-weight: 800;
}

.grid-thumb-meta {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  font-size: 12px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 6px 18px rgba(0, 0, 0, 0.7);
  opacity: 0.95;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}


/* FULL-SCREEN PROFILE VIEWER */
.viewer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 10001;
}

.viewer {
  position: absolute;
  inset: 0;
  background: #000;
  display: flex;
  flex-direction: column;
}

.viewer-topbar {
  height: 56px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 5;
}

.viewer-close {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.viewer-creator {
  font-weight: 900;
  opacity: 0.95;
}

.viewer-feed {
  flex: 1;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
}

.viewer-feed .viewer-video {
  height: 100%;
  min-height: 100vh;
  scroll-snap-align: start;
  position: relative;
}

.viewer-feed iframe {
  width: 100%;
  height: 100%;
}

.viewer-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 16px 70px;
  z-index: 10;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 20%, rgba(0, 0, 0, 0.78) 100%);
  pointer-events: none;
}

.viewer-title {
  font-weight: 800;
  margin-bottom: 10px;
}

.viewer-actions {
  display: flex;
  gap: 10px;
  pointer-events: auto;
  flex-wrap: wrap;
}

.viewer-action {
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.viewer-action:active {
  transform: scale(0.98);
}

.viewer-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* POST MENU (Edit/Delete) */
.postmenu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 12000;
  display: none;
}

.postmenu-backdrop:not([hidden]) {
  display: block;
}

.postmenu {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 12001;
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  background: rgba(17, 17, 17, 0.98);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  display: none;
}

.postmenu:not([hidden]) {
  display: block;
}

.postmenu-btn {
  width: 100%;
  padding: 14px 14px;
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

.postmenu-btn-danger {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.12);
  color: #fecaca;
}

.postmenu-btn-cancel {
  border-color: rgba(250, 204, 21, 0.35);
  background: rgba(250, 204, 21, 0.10);
  color: #facc15;
}

.postmenu-btn:active {
  transform: scale(0.99);
}

/* ANIMATIONS */
@keyframes fadeOut {
  to {
    opacity: 0;
    visibility: hidden;
  }
}










