/* HWHub Social - App Styles */
:root {
  --bg: #000;
  --bg-1: #0a0a0a;
  --bg-2: #141414;
  --bg-3: #1e1e1e;
  --border: #262626;
  --text: #f5f5f5;
  --text-mute: #8e8e8e;
  --accent: #8b5cf6;
  --accent-2: #ec4899;
  --grad: linear-gradient(135deg, #8b5cf6 0%, #ec4899 50%, #f59e0b 100%);
  --grad-story: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  --success: #10b981;
  --danger: #ef4444;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  min-height: 100vh;
  padding-bottom: 70px;
  overflow-x: hidden;
}

/* Hide PWA install banner when app is launched standalone */
@media (display-mode: standalone) {
  .pwa-banner { display: none !important; }
}
img, video { max-width: 100%; display: block; }
a { color: var(--text); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ============ Top Bar ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(0,0,0,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 600px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  text-decoration: none;
}
.brand-logo { width: 30px; height: 30px; display: block; }
.brand span {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 50%, #d97706 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 700;
}
.topbar-icons { display: flex; gap: 18px; align-items: center; }
.topbar-icons a { position: relative; font-size: 1.4rem; }
.icon-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  background: var(--danger);
  color: white;
  border-radius: 999px;
  min-width: 16px;
  height: 16px;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ============ Bottom Nav ============ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  z-index: 50;
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 2px;
  color: var(--text-mute);
  gap: 2px;
  min-width: 0;
}
.bottom-nav a .nav-icon { font-size: 1.35rem; line-height: 1; }
.bottom-nav a .nav-label { font-size: 0.62rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.bottom-nav a.active { color: var(--text); }
.bottom-nav a.active .nav-icon { transform: scale(1.1); }
.bottom-nav .nav-add .nav-icon {
  background: var(--grad);
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  color: white;
  font-size: 1.3rem;
}

/* ============ Container ============ */
.container { max-width: 600px; margin: 0 auto; padding: 0; }
.container-wide { max-width: 940px; margin: 0 auto; padding: 0 16px; }

/* ============ Stories carousel ============ */
.stories-bar {
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.stories-bar::-webkit-scrollbar { display: none; }
.stories-inner { display: flex; gap: 12px; padding: 0 14px; }
.story-thumb {
  flex-shrink: 0;
  text-align: center;
  width: 72px;
}
.story-thumb-img {
  width: 64px; height: 64px;
  border-radius: 50%;
  padding: 2px;
  background: var(--grad-story);
  margin: 0 auto;
  cursor: pointer;
}
.story-thumb-img.seen { background: var(--border); }
.story-thumb-img.add { background: var(--bg-3); display: flex; align-items: center; justify-content: center; }
.story-thumb-img img {
  width: 100%; height: 100%;
  border-radius: 50%;
  border: 3px solid var(--bg-1);
  object-fit: cover;
}
.story-thumb-img.add::before {
  content: '+';
  font-size: 2rem;
  color: var(--text);
  font-weight: 300;
}
.story-thumb-name {
  font-size: 0.72rem;
  color: var(--text-mute);
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============ Post Card ============ */
.post {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.post-head {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  gap: 10px;
}
.post-head-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  padding: 2px;
  background: var(--grad-story);
}
.post-head-avatar img {
  width: 100%; height: 100%;
  border-radius: 50%;
  border: 2px solid var(--bg);
  object-fit: cover;
}
.post-head-name { font-weight: 700; font-size: 0.92rem; flex: 1; }
.post-head-name a { color: var(--text); }
.post-head-name .sub { color: var(--text-mute); font-weight: 400; font-size: 0.8rem; display: block; }
.post-head .post-menu { color: var(--text-mute); font-size: 1.3rem; padding: 4px 8px; }

.post-image {
  width: 100%;
  background: var(--bg-1);
  position: relative;
  overflow: hidden;
}
.post-image > img, .post-image > video {
  width: 100%;
  display: block;
  max-height: 80vh;
  object-fit: contain;
  background: #000;
}
.post-tag {
  position: absolute;
  top: 12px; left: 12px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  color: white;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.post-tag.homework { background: rgba(245,158,11,0.85); }
.post-tag.classwork { background: rgba(99,102,241,0.85); }

.post-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px 4px;
}
.post-action {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  padding: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: transform 0.15s;
}
.post-action:active { transform: scale(0.85); }
.post-action.liked { color: var(--danger); }
.post-action .count { font-size: 0.85rem; font-weight: 600; color: var(--text); }

.post-body { padding: 4px 14px 14px; }
.post-likes { font-weight: 700; font-size: 0.88rem; margin-bottom: 4px; }
.post-caption { font-size: 0.92rem; white-space: pre-wrap; word-break: break-word; }
.post-caption .username { font-weight: 700; margin-right: 6px; }
.post-meta { font-size: 0.7rem; color: var(--text-mute); text-transform: uppercase; margin-top: 8px; letter-spacing: 0.5px; }
.post-hw-info {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg-2);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  font-size: 0.88rem;
}
.post-hw-info .label { font-size: 0.7rem; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.5px; }

/* ============ Cards & Forms ============ */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin: 16px;
}
.card h2 { font-size: 1.1rem; margin-bottom: 14px; font-weight: 700; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-control {
  width: 100%;
  padding: 13px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--accent); background: var(--bg-3); }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-help { font-size: 0.78rem; color: var(--text-mute); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 22px;
  background: var(--grad);
  color: white;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  transition: transform 0.1s;
}
.btn:active { transform: scale(0.97); }
.btn-secondary { background: var(--bg-3); color: var(--text); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 7px 14px; font-size: 0.82rem; border-radius: 8px; }
.btn-block { width: 100%; }

.flash {
  padding: 11px 14px;
  border-radius: 10px;
  margin: 12px 16px;
  font-size: 0.9rem;
}
.flash.success { background: rgba(16,185,129,0.15); color: #6ee7b7; }
.flash.error { background: rgba(239,68,68,0.15); color: #fca5a5; }

/* ============ Auth pages ============ */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at 20% 10%, rgba(139,92,246,0.15), transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(236,72,153,0.15), transparent 50%),
    var(--bg);
}
.auth-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.auth-logo {
  text-align: center;
  font-size: 2.4rem;
  font-weight: 900;
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
  letter-spacing: -1px;
}
.auth-sub {
  text-align: center;
  color: var(--text-mute);
  margin-bottom: 24px;
  font-size: 0.92rem;
}
.auth-switch {
  text-align: center;
  margin-top: 18px;
  font-size: 0.88rem;
  color: var(--text-mute);
}
.auth-switch a { color: var(--accent); font-weight: 700; }

/* ============ Profile ============ */
.profile-head {
  padding: 20px 16px;
  display: flex;
  gap: 24px;
  align-items: center;
}
.profile-avatar {
  width: 86px; height: 86px;
  border-radius: 50%;
  padding: 3px;
  background: var(--grad-story);
  flex-shrink: 0;
}
.profile-avatar img {
  width: 100%; height: 100%;
  border-radius: 50%;
  border: 3px solid var(--bg);
  object-fit: cover;
}
.profile-stats {
  flex: 1;
  display: flex;
  justify-content: space-around;
}
.profile-stat { text-align: center; }
.profile-stat-num { font-weight: 700; font-size: 1.1rem; }
.profile-stat-label { font-size: 0.78rem; color: var(--text-mute); }

.profile-info { padding: 0 16px 16px; }
.profile-name { font-weight: 700; font-size: 1rem; }
.profile-bio { font-size: 0.92rem; margin-top: 4px; color: var(--text); white-space: pre-wrap; }
.profile-handle { color: var(--text-mute); font-size: 0.85rem; }
.profile-actions { display: flex; gap: 8px; padding: 0 16px 16px; }
.profile-actions .btn { flex: 1; }

.profile-tabs {
  display: flex;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.profile-tabs a {
  flex: 1;
  text-align: center;
  padding: 12px 0;
  color: var(--text-mute);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.profile-tabs a.active { color: var(--text); border-top: 2px solid var(--text); margin-top: -1px; }

.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}
.profile-grid a {
  aspect-ratio: 1;
  background: var(--bg-2);
  position: relative;
  overflow: hidden;
}
.profile-grid img { width: 100%; height: 100%; object-fit: cover; }
.profile-grid .grid-tag {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(0,0,0,0.7);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.62rem;
  text-transform: uppercase;
}

/* ============ Messages ============ */
.thread-list { padding: 0; }
.thread-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.thread-item:hover { background: var(--bg-1); }
.thread-avatar {
  width: 50px; height: 50px;
  border-radius: 50%;
  padding: 2px;
  background: var(--grad-story);
  flex-shrink: 0;
}
.thread-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 2px solid var(--bg); }
.thread-meta { flex: 1; min-width: 0; }
.thread-name { font-weight: 600; font-size: 0.92rem; }
.thread-preview { font-size: 0.82rem; color: var(--text-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.thread-time { font-size: 0.72rem; color: var(--text-mute); margin-left: 8px; }
.thread-item.unread .thread-preview { color: var(--text); font-weight: 600; }
.thread-item.unread::after {
  content: '';
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  margin-left: auto;
}

/* ============ Chat ============ */
.chat-header {
  position: sticky;
  top: 0;
  background: rgba(0,0,0,0.95);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  z-index: 20;
}
.chat-header a.back { color: var(--text); font-size: 1.4rem; }
.chat-header-info { flex: 1; }
.chat-header-name { font-weight: 700; }
.chat-header-status { font-size: 0.72rem; color: var(--text-mute); }
.chat-thread {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: calc(100vh - 200px);
}
.bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 22px;
  font-size: 0.95rem;
  word-wrap: break-word;
  white-space: pre-wrap;
  position: relative;
}
.bubble.me {
  background: var(--grad);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 6px;
}
.bubble.them {
  background: var(--bg-2);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 6px;
}
.bubble-time { font-size: 0.65rem; opacity: 0.7; margin-top: 4px; }
.bubble img { border-radius: 12px; max-width: 240px; margin-bottom: 4px; }
.chat-compose {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 40;
}
body.no-bottom-nav { padding-bottom: 0; }
body.no-bottom-nav .chat-thread { padding-bottom: 80px; min-height: calc(100vh - 130px); }
/* Reserve room for the sticky comment-form on post pages */
.comments-section { padding-bottom: 24px; }
.chat-compose input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.95rem;
}
.chat-compose input:focus { outline: none; border-color: var(--accent); }
.chat-compose button {
  background: var(--grad);
  border: none;
  color: white;
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 1.1rem;
}

/* ============ Discover / AI ============ */
.ai-banner {
  margin: 12px 16px;
  padding: 16px 18px;
  background: var(--grad);
  border-radius: 16px;
  position: relative;
  overflow: hidden;
}
.ai-banner::before {
  content: '✨';
  position: absolute;
  top: -20px; right: -20px;
  font-size: 8rem;
  opacity: 0.15;
}
.ai-banner-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.8;
}
.ai-banner-msg { font-size: 1rem; margin-top: 4px; line-height: 1.5; }

.suggest-grid {
  padding: 0 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.suggest-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.suggest-card .avatar-sm {
  width: 48px; height: 48px;
  border-radius: 50%;
  padding: 2px;
  background: var(--grad-story);
  flex-shrink: 0;
}
.suggest-card .avatar-sm img { width: 100%; height: 100%; border-radius: 50%; border: 2px solid var(--bg-1); object-fit: cover; }
.suggest-info { flex: 1; min-width: 0; }
.suggest-name { font-weight: 700; font-size: 0.92rem; }
.suggest-handle { font-size: 0.78rem; color: var(--text-mute); }
.suggest-mutual { font-size: 0.72rem; color: var(--accent); margin-top: 2px; }

/* ============ Stories Viewer ============ */
.story-viewer {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 100;
  display: flex;
  flex-direction: column;
}
.story-viewer img, .story-viewer video {
  flex: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.story-viewer-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 16px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent);
  z-index: 2;
}
.story-progress {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}
.story-progress-bar {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  overflow: hidden;
}
.story-progress-bar .fill {
  height: 100%;
  background: white;
  width: 0;
  transition: width linear;
}
.story-viewer-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
}
.story-viewer-user img { width: 32px; height: 32px; border-radius: 50%; }
.story-viewer-close {
  position: absolute;
  top: 16px; right: 16px;
  background: none;
  border: none;
  color: white;
  font-size: 1.6rem;
  z-index: 3;
  padding-top: 30px;
}
.story-caption {
  position: absolute;
  bottom: 40px;
  left: 16px; right: 16px;
  color: white;
  text-align: center;
  text-shadow: 0 2px 6px rgba(0,0,0,0.8);
  font-size: 0.95rem;
  z-index: 2;
}

/* ============ Upload page ============ */
.upload-tabs {
  display: flex;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.upload-tabs::-webkit-scrollbar { display: none; }
.upload-tabs a {
  flex: 1 0 auto;
  min-width: 0;
  text-align: center;
  padding: 14px 16px;
  color: var(--text-mute);
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  text-decoration: none;
}
.upload-tabs a.active { color: var(--text); border-bottom-color: var(--accent); }

.file-drop {
  border: 2px dashed var(--border);
  border-radius: 14px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  background: var(--bg-1);
  margin: 16px;
}
.file-drop {
  display: block;          /* label as block — fixes the inline-rendering artifact */
  position: relative;
}
.file-drop:hover, .file-drop.drag { border-color: var(--accent); background: rgba(139,92,246,0.05); }
/* Hide the native file input — the surrounding <label> still routes clicks to it */
.file-drop input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
}
.multi-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.multi-preview:empty { display: none; }
.preview-tile {
  position: relative;
  aspect-ratio: 1;
  background: var(--bg-2);
  border-radius: 8px;
  overflow: hidden;
}
.preview-tile img, .preview-tile video {
  width: 100%; height: 100%;
  object-fit: cover;
}
.preview-badge {
  position: absolute;
  bottom: 4px; left: 4px;
  background: rgba(0,0,0,0.7);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.62rem;
  font-weight: 700;
}
.preview-tile { cursor: pointer; border: 2px solid transparent; }
.preview-tile.cover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.preview-tile.cover::before {
  content: '⭐ COVER';
  position: absolute;
  top: 4px; left: 4px;
  background: var(--grad);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  z-index: 2;
}
.cover-hint {
  font-size: 0.78rem;
  color: var(--text-mute);
  text-align: center;
  margin-top: 6px;
}
.file-drop-icon { font-size: 3rem; margin-bottom: 10px; }
.file-drop-text { font-weight: 700; }
.file-drop-sub { font-size: 0.82rem; color: var(--text-mute); margin-top: 4px; }
.preview-image {
  max-width: 100%;
  max-height: 360px;
  border-radius: 12px;
  margin: 12px auto;
  display: block;
}

/* ============ Notifications ============ */
.notif-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.notif-item.unread { background: rgba(139,92,246,0.05); }
.notif-item .avatar-sm { width: 44px; height: 44px; border-radius: 50%; padding: 2px; background: var(--grad-story); flex-shrink: 0; }
.notif-item .avatar-sm img { width: 100%; height: 100%; border-radius: 50%; border: 2px solid var(--bg); object-fit: cover; }
.notif-text { flex: 1; font-size: 0.9rem; }
.notif-time { font-size: 0.72rem; color: var(--text-mute); }

/* ============ Search ============ */
.search-bar {
  padding: 10px 16px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
}
.search-bar input {
  width: 100%;
  padding: 11px 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.95rem;
}

/* ============ Empty states ============ */
.empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-mute);
}
.empty-icon { font-size: 3.5rem; margin-bottom: 12px; opacity: 0.5; }
.empty h3 { color: var(--text); margin-bottom: 6px; font-size: 1.1rem; }

/* ============ Ad slot ============ */
.ad-slot {
  margin: 14px 16px;
  padding: 12px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: center;
  min-height: 60px;
  overflow: hidden;
}
.ad-slot:empty { display: none; }
.ad-label { font-size: 0.65rem; color: var(--text-mute); text-transform: uppercase; letter-spacing: 1px; }

/* ============ PWA install banner ============ */
.pwa-banner {
  position: fixed;
  bottom: 80px;
  left: 16px; right: 16px;
  background: var(--grad);
  color: white;
  padding: 14px 18px;
  border-radius: 14px;
  display: none;
  align-items: center;
  gap: 14px;
  z-index: 40;
  box-shadow: 0 10px 30px rgba(139,92,246,0.4);
}
.pwa-banner.show { display: flex; }
.pwa-banner-text { flex: 1; font-size: 0.88rem; }
.pwa-banner-text strong { display: block; font-size: 0.95rem; }
.pwa-banner button {
  background: white;
  color: var(--accent);
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
}
.pwa-banner .close {
  background: rgba(255,255,255,0.2);
  color: white;
  width: 28px; height: 28px;
  padding: 0;
  border-radius: 50%;
  font-size: 0.9rem;
}

/* ============ AI Chat ============ */
.ai-hero {
  padding: 20px 16px;
  background: var(--grad);
  position: relative;
  overflow: hidden;
}
.ai-hero::before {
  content: '🤖';
  position: absolute;
  top: -16px; right: -16px;
  font-size: 6rem;
  opacity: 0.15;
}
.ai-hero h2 { font-size: 1.4rem; font-weight: 800; }
.ai-hero p { font-size: 0.88rem; opacity: 0.95; margin-top: 4px; }
.ai-suggestion-chips {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.ai-suggestion-chips::-webkit-scrollbar { display: none; }
.ai-suggestion-chips button {
  flex-shrink: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  white-space: nowrap;
}
.ai-suggestion-chips button:hover { background: var(--bg-3); border-color: var(--accent); }
.ai-typing { display: flex; gap: 4px; padding: 12px 14px; }
.ai-typing span { width: 8px; height: 8px; border-radius: 50%; background: var(--text-mute); animation: typing 1.4s infinite; }
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

/* ============ Carousel for multi-image posts (Instagram-style swipe) ============ */
.carousel {
  position: relative;
  width: 100%;
  overflow: hidden;
}
.carousel-track {
  display: flex;
  flex-wrap: nowrap;
  width: 100%;
  scroll-snap-type: x mandatory;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  touch-action: pan-x;       /* tell the browser horizontal swipe = carousel, vertical = page scroll */
  overscroll-behavior-x: contain;
}
.carousel-track::-webkit-scrollbar { display: none; }
.carousel-slide {
  flex: 0 0 100%;
  width: 100%;
  min-width: 100%;
  max-width: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 80vh;
}
.carousel-slide img, .carousel-slide video {
  width: 100%;
  height: auto;
  max-height: 80vh;
  object-fit: contain;
  display: block;
}
/* Arrow buttons (desktop) */
.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.5);
  color: white;
  border: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.2s;
}
.carousel:hover .carousel-arrow { opacity: 1; }
.carousel-arrow.prev { left: 8px; }
.carousel-arrow.next { right: 8px; }
.carousel-arrow:disabled { opacity: 0 !important; pointer-events: none; }
@media (hover: none) { .carousel-arrow { display: none; } }
.carousel-dots {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  pointer-events: none;
}
.carousel-dots span {
  width: 6px; height: 6px;
  background: rgba(255,255,255,0.5);
  border-radius: 50%;
  transition: all 0.2s;
}
.carousel-dots span.active { background: white; width: 18px; border-radius: 999px; }
.carousel-count {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.6);
  color: white;
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 999px;
  pointer-events: none;
  backdrop-filter: blur(8px);
}

/* ============ Video in posts/stories ============ */
.post-image video, .preview-image video { width: 100%; display: block; }
video.story-video { width: 100%; height: 100%; object-fit: contain; background: #000; }

/* ============ Comments ============ */
.comments-section { padding: 16px; border-top: 1px solid var(--border); }
.comments-section h3 {
  font-size: 0.95rem;
  margin-bottom: 12px;
  color: var(--text);
}
.comment {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg-2);
}
.comment:last-child { border-bottom: none; }
.comment-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  padding: 2px;
  background: var(--grad-story);
}
.comment-avatar img {
  width: 100%; height: 100%;
  border-radius: 50%;
  border: 2px solid var(--bg);
  object-fit: cover;
}
.comment-body { flex: 1; min-width: 0; }
.comment-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.82rem;
  margin-bottom: 2px;
}
.comment-meta .username { font-weight: 700; color: var(--text); }
.comment-meta .time { color: var(--text-mute); font-size: 0.72rem; }
.comment-text {
  font-size: 0.92rem;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.comment-form {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  align-items: center;
}
.comment-form input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.92rem;
}
.comment-form input:focus { outline: none; border-color: var(--accent); }
.comment-form button {
  background: var(--grad);
  color: white;
  border: none;
  padding: 9px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.88rem;
}

/* ============ Spinner ============ */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 24px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Desktop tweaks */
@media (min-width: 700px) {
  body { padding-bottom: 0; }
  .bottom-nav { display: none; }
  .topbar { padding-right: 80px; }
  .desktop-nav {
    position: fixed;
    top: 0; right: 0;
    height: 100vh;
    width: 200px;
    background: var(--bg-1);
    border-left: 1px solid var(--border);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .desktop-nav a {
    padding: 12px 14px;
    border-radius: 10px;
    display: flex;
    gap: 12px;
    align-items: center;
    font-weight: 600;
    color: var(--text-mute);
  }
  .desktop-nav a.active { color: var(--text); background: var(--bg-2); }
  .desktop-nav a:hover { background: var(--bg-2); color: var(--text); }
  .container { margin-right: 200px; }
  .chat-compose { right: 200px; bottom: 0; }
}
@media (max-width: 699px) {
  .desktop-nav { display: none; }
}
