/* ================================================================
   SBD NETWORK - MOBILE-FIRST PWA STYLES
   Dark Modern Interface
   ================================================================ */

/* ============= RESET & BASE ============= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Prevent images/video/iframes from blowing past the viewport width */
img, video, iframe {
  max-width: 100%;
  height: auto;
}

html {
  /* Prevent any element from creating a horizontal scrollbar at the page level */
  overflow-x: hidden;
}

:root {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0a;
  --bg-card: #1a1a1a;
  --bg-hover: #2a2a2a;
  --accent-primary: #00bcd4;
  --accent-hover: #00acc1;
  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
  --text-muted: #707070;
  --border-color: #333333;
  --error: #ff5252;
  --success: #4caf50;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.7);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ============= HEADER ============= */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  /* Grow header to clear iPhone notch / Dynamic Island */
  height: calc(60px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-left: 16px;
  padding-right: 16px;
  z-index: 1000;
  box-shadow: var(--shadow);
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-primary);
}

.page-title {
  font-size: 18px;
  font-weight: 600;
}

.user-name {
  font-size: 14px;
  color: var(--text-secondary);
  display: none;
}

/* ── Notification Bell ──────────────────────────────────────────── */
.notif-bell-btn {
  position: relative;
  font-size: 1.2rem;
  line-height: 1;
  padding: 6px 8px;
}

.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  background: #ff4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
}

/* ── Notification Panel ─────────────────────────────────────────── */
.notif-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1100;
}

.notif-panel {
  position: fixed;
  top: 0;
  right: -360px;
  width: 340px;
  max-width: 92vw;
  height: 100%;
  background: var(--bg-card);
  border-left: 1px solid var(--border-color);
  z-index: 1101;
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.notif-panel.open {
  right: 0;
}

.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.notif-panel-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.notif-panel-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.notif-clear-all-btn {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent-gold, #c9a227);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
}

.notif-clear-all-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.notif-panel-footer {
  font-size: 0.72rem;
  line-height: 1.4;
  padding: 12px 16px 16px;
  text-align: center;
  color: var(--text-muted, #888);
}

.notif-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  transition: background 0.15s;
}

.notif-item:hover {
  background: rgba(255,255,255,0.04);
}

.notif-item.unread {
  background: rgba(255,255,255,0.07);
}

.ni-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  padding-top: 1px;
}

.ni-body {
  flex: 1;
  min-width: 0;
}

.ni-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ni-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ni-time {
  font-size: 0.72rem;
  color: var(--text-secondary);
  opacity: 0.6;
  margin-top: 4px;
}

.notif-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  list-style: none;
}

/* ============= FOREGROUND TOAST ============= */
.notif-toast {
  position: fixed;
  top: 70px; /* below the app header */
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  opacity: 0;
  z-index: 1200;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 12px 16px;
  width: calc(100% - 32px);
  max-width: 420px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.55);
  cursor: pointer;
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1), opacity 0.35s ease;
  -webkit-tap-highlight-color: transparent;
}
.notif-toast--in {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.notif-toast-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  padding-top: 1px;
}
.notif-toast-body { flex: 1; min-width: 0; }
.notif-toast-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.notif-toast-text {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============= BUTTONS ============= */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  outline: none;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: var(--accent-primary);
  color: var(--bg-primary);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 188, 212, 0.4);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-danger {
  background: var(--error);
  color: white;
}

.btn-danger:hover {
  background: #ff6b6b;
}

.btn-link {
  background: none;
  color: var(--accent-primary);
  padding: 4px 8px;
}

.btn-link:hover {
  text-decoration: underline;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}

.btn-icon:hover {
  background: var(--bg-hover);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

/* ============= AUTHENTICATION PAGE ============= */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  min-height: -webkit-fill-available;
  padding: 20px;
  background: linear-gradient(135deg, #000000 0%, #1a1a1a 100%);
}

.auth-container {
  width: 100%;
  max-width: 420px;
}

.auth-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent-primary);
  margin-bottom: 8px;
}

.auth-tagline {
  color: var(--text-secondary);
  font-size: 14px;
}

.auth-form h2 {
  font-size: 24px;
  margin-bottom: 24px;
  text-align: center;
}

/* ── Remember me row ──────────────────────────────────────────── */
.remember-row {
  margin: 4px 0 16px;
}

.remember-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  color: rgba(255,255,255,0.6);
  user-select: none;
}

.remember-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #fff;
  cursor: pointer;
  flex-shrink: 0;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.form-group small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.form-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-secondary);
}

.form-footer a {
  color: var(--accent-primary);
  text-decoration: none;
  font-weight: 600;
}

.form-footer a:hover {
  text-decoration: underline;
}

.auth-message {
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  text-align: center;
  font-size: 14px;
  display: none;
}

.auth-message.success {
  background: rgba(76, 175, 80, 0.2);
  color: var(--success);
  border: 1px solid var(--success);
}

.auth-message.error {
  background: rgba(255, 82, 82, 0.2);
  color: var(--error);
  border: 1px solid var(--error);
}

/* ============= DASHBOARD ============= */
.dashboard-page,
.group-page,
.board-page,
.admin-page {
  padding-top: 60px;
  min-height: 100%;
}

.dashboard-main,
.group-main,
.board-main,
.admin-main {
  padding: 20px 16px;
  max-width: 1200px;
  margin: 0 auto;
}

.welcome-section {
  margin-bottom: 32px;
  text-align: center;
}

.welcome-section h2 {
  font-size: 28px;
  margin-bottom: 8px;
}

.welcome-subtitle {
  color: var(--text-secondary);
  font-size: 16px;
}

.dashboard-section {
  margin-bottom: 40px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section-header h3 {
  font-size: 20px;
  font-weight: 600;
}

/* ============= GRIDS ============= */
.groups-grid,
.boards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 768px) {
  .groups-grid,
  .boards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .groups-grid,
  .boards-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .user-name {
    display: block;
  }
}

/* ============= CARDS ============= */
.group-card,
.board-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.board-card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.board-last-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.board-last-preview {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-card:hover,
.board-card:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.group-icon,
.board-icon {
  width: 48px;
  height: 48px;
  background: var(--accent-primary);
  color: var(--bg-primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
}

.group-title,
.board-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.group-description,
.board-description {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.group-footer,
.board-footer {
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.group-meta,
.board-meta {
  font-size: 13px;
  color: var(--text-muted);
}

/* ============= ACTIVITY LIST ============= */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.activity-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.activity-item:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
}

.activity-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.activity-author {
  font-weight: 600;
  font-size: 14px;
}

.activity-board {
  font-size: 11px;
  color: var(--accent-primary);
  background: rgba(0, 212, 255, 0.08);
  border-radius: 8px;
  padding: 1px 7px;
  margin-left: 4px;
  flex-shrink: 0;
}

.activity-time {
  font-size: 12px;
  color: var(--text-muted);
}

.activity-preview {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ============= POSTS FEED ============= */
.posts-feed {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
}

.post-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.post-author-info {
  flex: 1;
}

.post-author {
  display: block;
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}

.post-time {
  font-size: 13px;
  color: var(--text-muted);
}

.delete-post-btn {
  font-size: 18px;
  opacity: 0.7;
}

.delete-post-btn:hover {
  opacity: 1;
  color: var(--error);
}

.post-content {
  margin-bottom: 16px;
  line-height: 1.6;
}

.post-content p {
  margin-bottom: 12px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.post-image {
  width: 100%;
  border-radius: 8px;
  margin-top: 12px;
}

.video-container {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  margin-top: 12px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-secondary);
}

.video-container iframe,
.video-container video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 8px;
}

.post-footer {
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.comment-toggle-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 0;
}

.comment-toggle-btn:hover {
  color: var(--accent-primary);
}

/* ============= COMMENTS ============= */
.comments-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.comments-list {
  margin-bottom: 16px;
}

.comment-item {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
}

.comment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.comment-author {
  font-weight: 600;
  font-size: 14px;
}

.comment-time {
  font-size: 12px;
  color: var(--text-muted);
}

.delete-comment-btn {
  color: var(--text-muted);
  font-size: 20px;
}

.delete-comment-btn:hover {
  color: var(--error);
}

.comment-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.no-comments {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 12px;
}

.comment-form {
  display: flex;
  gap: 8px;
}

.comment-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  overflow: hidden;
  min-height: 40px;
  max-height: 160px;
  line-height: 1.4;
}

.comment-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

/* ============= FLOATING ACTION BUTTON ============= */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  background: var(--accent-primary);
  color: var(--bg-primary);
  border: none;
  border-radius: 50%;
  font-size: 28px;
  font-weight: 300;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 188, 212, 0.5);
  transition: all 0.3s ease;
  z-index: 999;
}

.fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 188, 212, 0.6);
}

.fab-icon {
  display: block;
  line-height: 1;
}

/* ============= MODAL ============= */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 24px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

/* Scrollable body inside manage-user modal */
#manageUserContent {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

#manageUserContent .modal-actions {
  margin-top: auto;
  padding-top: 16px;
  position: sticky;
  bottom: 0;
  background: var(--bg-card);
  z-index: 1;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-header h3 {
  font-size: 22px;
  font-weight: 600;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.modal-actions .btn {
  flex: 1;
}

.edit-post-textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
  box-sizing: border-box;
}

.edit-post-textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.modal-body {
  margin-bottom: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.post-form textarea {
  min-height: 120px;
  resize: vertical;
}

/* ── Telegram-style post modal ───────────────────────────────────── */
.post-modal-content {
  padding: 16px 16px 20px;
}

/* Caption field — borderless, clean, like Telegram's compose */
.post-caption-input {
  width: 100%;
  min-height: 72px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  outline: none;
  padding: 4px 2px 12px;
  box-sizing: border-box;
}
.post-caption-input::placeholder { color: var(--text-muted); }

/* Media thumbnail grid shown after picking files */
.media-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  margin: 12px 0 0;
  border-radius: 10px;
  overflow: hidden;
}

.media-thumb-item {
  position: relative;
  aspect-ratio: 1;
  background: #111;
  overflow: hidden;
}

.media-thumb-item img,
.media-thumb-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.media-thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  background: rgba(0,0,0,0.7);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 1;
}

.media-thumb-edit {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  background: rgba(0, 100, 210, 0.75);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 0.65rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 1;
}

.media-thumb-video-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(0,0,0,0.6);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.62rem;
  color: #fff;
  pointer-events: none;
}

/* Per-thumbnail upload overlay */
.media-thumb-uploading {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  pointer-events: none;
}

.media-thumb-spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: thumbSpin 0.7s linear infinite;
}

@keyframes thumbSpin {
  to { transform: rotate(360deg); }
}

.media-thumb-done {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  pointer-events: none;
}

/* "Add Photos or Videos" dashed button */
.add-media-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1.5px dashed var(--border-color);
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-family: inherit;
  padding: 14px 16px;
  cursor: pointer;
  margin-top: 14px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-align: left;
}
.add-media-btn:hover,
.add-media-btn:active {
  background: rgba(255,255,255,0.09);
  border-color: var(--accent-primary);
  color: var(--text-primary);
}
.add-media-icon { font-size: 1.3rem; line-height: 1; }

.image-preview {
  margin-top: 16px;
}

.image-preview img {
  max-width: 100%;
  border-radius: 8px;
}

/* ============= ADMIN PANEL ============= */
.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
}

.tab-btn {
  padding: 12px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.admin-tab {
  display: none;
}

.admin-tab.active {
  display: block;
}

.admin-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
}

.admin-card h4 {
  font-size: 18px;
  margin-bottom: 8px;
}

.admin-card p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 8px;
}

.small-text {
  font-size: 13px;
  color: var(--text-muted);
}

.admin-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
}

/* Archived / suspended cards */
.admin-card-archived {
  opacity: 0.55;
  border-style: dashed;
}

/* Admin tier badge */
.admin-tier-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.tier-free    { background: rgba(168,162,158,0.15); color: #A8A29E; }
.tier-foundation { background: rgba(96,165,250,0.15); color: #60A5FA; }
.tier-premium { background: rgba(167,139,250,0.15); color: #A78BFA; }
.tier-elite   { background: rgba(198,169,107,0.18); color: #C6A96B; border: 1px solid rgba(198,169,107,0.3); }

/* Admin group header separator in boards list */
.admin-group-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 14px 0 6px;
  border-top: 1px solid var(--border-color);
  margin-top: 8px;
}
.admin-group-header:first-child { border-top: none; margin-top: 0; }

/* Board card slight indent under group */
.admin-card--board {
  margin-left: 0;
  border-left: 2px solid rgba(198,169,107,0.2);
}

.badge-archived {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 6px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Admin manage user sections */
.admin-manage-section {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}
.admin-manage-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.admin-manage-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Admin dropdown select */
.admin-select {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
}

.groups-checklist {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 400px;
  overflow-y: auto;
  margin: 16px 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.checkbox-label:hover {
  background: var(--bg-hover);
}

.checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

/* ============= LOADING & EMPTY STATES ============= */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text,
.error-text {
  text-align: center;
  padding: 32px;
  color: var(--text-secondary);
  font-size: 14px;
}

.error-text {
  color: var(--error);
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state p {
  margin-bottom: 8px;
  font-size: 15px;
}

/* ============= SKELETON LOADING SCREENS ============= */
@keyframes skeleton-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: calc(400px + 100%) 0; }
}

.skel-line,
.skel-icon,
.skel-thumb {
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.04) 25%,
    rgba(255,255,255,0.09) 50%,
    rgba(255,255,255,0.04) 75%
  );
  background-size: 800px 100%;
  animation: skeleton-shimmer 1.5s infinite linear;
  border-radius: 5px;
}

/* Outer skeleton card container */
.skel-post,
.skel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Line heights */
.skel-line        { height: 12px; }
.skel-line.tall   { height: 180px; border-radius: 8px; }

/* Width variants */
.skel-line.w40 { width: 40%; }
.skel-line.w60 { width: 60%; }
.skel-line.w80 { width: 80%; }
.skel-line.w90 { width: 90%; }

/* Round icon placeholder (used in group/board cards) */
.skel-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Stop shimmer for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .skel-line, .skel-icon, .skel-thumb { animation: none; }
}

/* ============= GROUP/BOARD INFO ============= */
.group-info,
.board-info {
  margin-bottom: 32px;
  text-align: center;
}

.group-name,
.board-name {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.group-desc,
.board-desc {
  color: var(--text-secondary);
  font-size: 15px;
}

.boards-section,
.posts-section {
  margin-top: 32px;
}

.boards-section h3,
.posts-section h3 {
  font-size: 20px;
  margin-bottom: 20px;
}

/* ============= BOARDS PAGE — group sections ============= */
.boards-group-section {
  margin-bottom: 32px;
}

.boards-group-title {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 12px 2px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
}

/* ============= MOBILE OPTIMIZATIONS ============= */
@media (max-width: 767px) {
  .app-header {
    height: calc(56px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
    padding-left: 12px;
    padding-right: 12px;
  }
  
  .app-logo,
  .page-title {
    font-size: 16px;
  }
  
  .dashboard-main,
  .group-main,
  .board-main,
  .admin-main {
    padding: 16px 12px;
  }
  
  .welcome-section h2,
  .group-name,
  .board-name {
    font-size: 22px;
  }
  
  .modal-content {
    padding: 20px;
  }
  
  .fab {
    width: 48px;
    height: 48px;
    bottom: 20px;
    right: 20px;
    font-size: 24px;
  }
}

/* ============= ACCESSIBILITY ============= */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* ============= TOUCH ACTIVE PRESS STATES ============= */
/* On touch devices, give instant visual scale-down feedback on tap.
   Scoped to pointer:coarse so desktop hover/transitions are unaffected. */
@media (pointer: coarse) {
  /* Generic button press */
  .btn:active {
    transform: scale(0.95);
    transition: transform 0.08s ease;
  }
  .btn-primary:active {
    transform: scale(0.94);
    box-shadow: none;
  }
  /* Floating action button */
  .fab:active {
    transform: scale(0.88) !important;
    box-shadow: 0 2px 6px rgba(0,188,212,0.3) !important;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
  }
  /* Icon buttons (back, close, etc.) */
  .btn-icon:active {
    background: var(--bg-hover);
    transform: scale(0.9);
  }
  /* Nav tabs */
  .tab-btn:active,
  .admin-tab:active {
    opacity: 0.6;
    transform: scale(0.96);
  }
  /* Bottom nav items */
  .bottom-nav-btn:active {
    opacity: 0.65;
    transform: scale(0.9);
  }
}

/* Prevent transitions from interfering with touch feedback */
@media (pointer: coarse) and (prefers-reduced-motion: reduce) {
  .btn:active, .fab:active, .btn-icon:active { transform: none; }
}


/* ============= SCROLLBAR ============= */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── Push notification nudge bar ──────────────────────────────── */
#push-nudge {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #1a2f1f;
  border-top: 1px solid rgba(100, 220, 160, 0.35);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.5);
  animation: nudge-slide-up 0.35s ease;
}

@keyframes nudge-slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.push-nudge-text {
  flex: 1;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.85);
  line-height: 1.3;
}

.push-nudge-btn {
  flex-shrink: 0;
  padding: 8px 18px;
  background: #64dc9f;
  color: #0a1a0f;
  border: none;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.push-nudge-btn:hover {
  background: #80e8b0;
}

.push-nudge-x {
  flex-shrink: 0;
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 6px;
}

.push-nudge-x:hover {
  color: rgba(255,255,255,0.8);
}

/* ── PWA Install Banner ──────────────────────────────────────────── */
#pwa-install-banner {
  position: fixed;
  bottom: calc(68px + env(safe-area-inset-bottom));
  left: 12px;
  right: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 5000;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  transform: translateY(20px);
  opacity: 0;
  transition: opacity 0.28s, transform 0.28s;
}
#pwa-install-banner.pwa-banner-show {
  opacity: 1;
  transform: translateY(0);
}
.pwa-install-icon { font-size: 1.3rem; flex-shrink: 0; }
.pwa-install-text {
  flex: 1;
  font-size: 0.84rem;
  color: var(--text-primary);
}
.pwa-install-btn {
  background: var(--accent-primary);
  color: #000;
  border: none;
  border-radius: 10px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.pwa-install-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}

/* ── Pull-to-Refresh bar ───────────────────────────────────────── */
.ptr-bar {
  position: fixed;
  top: 60px;               /* JS overrides to match actual header height */
  left: 0;
  right: 0;
  height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  z-index: 990;
  opacity: 0;
  transition: height 0.15s ease, opacity 0.15s ease;
  font-size: 0.8rem;
  color: var(--text-muted);
  user-select: none;
  pointer-events: none;
}

.ptr-icon {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  flex-shrink: 0;
  display: block;
}

.ptr-icon.ptr-spin {
  animation: spin 0.7s linear infinite;
}

/* ── Mobile: safe-area insets ───────────────────────────────── */
/* FAB – keep above iPhone home indicator */
.fab {
  bottom: calc(24px + env(safe-area-inset-bottom));
}

/* Toast – keep above home indicator */
.app-toast {
  bottom: calc(24px + env(safe-area-inset-bottom));
}

/* Push-nudge bar – pad for home indicator */
#push-nudge {
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

/* ── Mobile: prevent iOS input zoom + long-word overflow ───────────── */
@media (max-width: 767px) {
  /* iOS zooms in on inputs with font-size < 16px – prevent that */
  .form-group input,
  .form-group textarea,
  .form-group select,
  .comment-input,
  .edit-post-textarea {
    font-size: 16px;
  }

  /* Long unbroken strings (URLs, etc.) shouldn’t overflow cards */
  .post-content p,
  .comment-text {
    word-break: break-word;
    overflow-wrap: break-word;
  }

  /* Prevent horizontal scroll jank from content overflow */
  body {
    overscroll-behavior-x: none;
  }
}

/* ================================================================
   EXPLORE PAGE
   ================================================================ */

.explore-main {
  padding: 70px 16px 90px;
  max-width: 700px;
  margin: 0 auto;
}

.explore-search-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: 0 12px;
}

.explore-search-icon {
  font-size: 1rem;
  opacity: 0.55;
  flex-shrink: 0;
}

.explore-search-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  padding: 10px 0;
  outline: none;
}

.explore-search-input::placeholder {
  color: var(--text-muted);
}

.explore-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 16px 0 10px;
}

.explore-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}

.explore-post-cell {
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--bg-card);
  display: block;
  position: relative;
  text-decoration: none;
}

.explore-post-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.explore-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

.explore-text-cell {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: center;
  overflow: hidden;
}

.explore-engagement {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.65);
  border-radius: 8px;
  padding: 2px 6px;
  font-size: 0.65rem;
  color: #fff;
}

.explore-person-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--border-color);
}

.explore-person-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 188, 212, 0.12);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--accent-primary);
  overflow: hidden;
  flex-shrink: 0;
  font-size: 1rem;
}

.explore-person-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.explore-person-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.explore-person-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: block;
  margin-top: 1px;
}

/* Clickable author names in posts */
.post-author-link {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
}

.post-author-link:hover {
  color: var(--accent-primary);
  text-decoration: underline;
}

/* Clickable author names in comments */
.comment-author-link {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

.comment-author-link:hover {
  color: var(--accent-primary);
  text-decoration: underline;
}

/* ================================================================
   LINK PREVIEW CARD
   ================================================================ */

.link-preview-card {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  margin: 6px 16px 2px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.link-preview-card:hover {
  opacity: 0.85;
}

.link-preview-img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-secondary);
}

.link-preview-body {
  padding: 10px;
  flex: 1;
  min-width: 0;
}

.link-preview-domain {
  font-size: 0.68rem;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.link-preview-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.link-preview-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 3px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ============= MENTIONS & HASHTAGS ============= */

/* Mention links */
.mention-link {
  color: var(--accent-primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.mention-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* Hashtag links */
.hashtag-link {
  color: #7cb342;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.hashtag-link:hover {
  color: #8bc34a;
  text-decoration: underline;
}

/* Mention autocomplete dropdown */
.mention-autocomplete {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
  z-index: 10000;
}

.mention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.mention-item:hover,
.mention-item.selected {
  background: var(--bg-hover);
}

.mention-item img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.mention-avatar-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
}

.mention-info {
  flex: 1;
  min-width: 0;
}

.mention-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mention-username {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============= SEARCH PAGE ============= */

.search-container {
  padding: 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0 12px;
}

.search-icon {
  font-size: 1.2rem;
  margin-right: 8px;
  color: var(--text-muted);
}

.search-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 1rem;
  padding: 12px 0;
  outline: none;
  font-family: inherit;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.clear-search-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  display: none;
  transition: color 0.2s ease;
}

.clear-search-btn:hover {
  color: var(--text-primary);
}

/* Search Tabs */
.search-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
}

.search-tab {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.875rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.search-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.search-tab.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #000;
  font-weight: 500;
}

/* Search Filters */
.toggle-filters-btn {
  background: transparent;
  border: none;
  color: var(--accent-primary);
  font-size: 0.875rem;
  padding: 12px 16px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.2s ease;
}

.toggle-filters-btn:hover {
  background: var(--bg-hover);
}

.search-filters {
  background: var(--bg-secondary);
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.filter-row:last-child {
  margin-bottom: 0;
}

.filter-row label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  min-width: 80px;
}

.filter-select,
.filter-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
}

.filter-select:focus,
.filter-input:focus {
  border-color: var(--accent-primary);
}

/* Results Counter */
.results-counter {
  padding: 12px 16px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

/* Search Results */
.search-results {
  padding: 16px;
}

.result-section {
  margin-bottom: 24px;
}

.result-section:last-child {
  margin-bottom: 0;
}

.result-section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  transition: all 0.2s ease;
}

.result-card:hover {
  border-color: var(--accent-primary);
  box-shadow: 0 2px 12px rgba(0, 188, 212, 0.1);
}

.result-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.result-author {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.result-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.result-content {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
  overflow-wrap: break-word;
}

.result-media {
  margin-bottom: 12px;
  border-radius: 8px;
  overflow: hidden;
}

.result-media img {
  width: 100%;
  display: block;
}

.result-actions {
  display: flex;
  justify-content: flex-end;
}

.result-link {
  color: var(--accent-primary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.2s ease;
}

.result-link:hover {
  color: var(--accent-hover);
}

/* Hashtag Cards */
.hashtag-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hashtag-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hashtag-tag {
  font-size: 1rem;
  font-weight: 600;
  color: #7cb342;
}

.hashtag-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* User Cards */
.user-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}

.user-avatar-placeholder {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
}

.user-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.user-username {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Placeholder */
.search-placeholder {
  text-align: center;
  padding: 60px 20px;
}

.search-placeholder-icon {
  font-size: 4rem;
  display: block;
  margin-bottom: 16px;
}

.search-placeholder p {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.search-suggestions {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 20px;
  text-align: left;
  max-width: 400px;
  margin: 0 auto;
}

.suggestions-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.search-suggestions ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.search-suggestions li {
  font-size: 0.875rem;
  color: var(--text-secondary);
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}

.search-suggestions li:last-child {
  border-bottom: none;
}

.search-suggestions strong {
  color: var(--accent-primary);
  font-weight: 500;
}

/* No Results */
.no-results {
  text-align: center;
  padding: 60px 20px;
}

.no-results-icon {
  font-size: 4rem;
  display: block;
  margin-bottom: 16px;
  filter: grayscale(100%);
  opacity: 0.5;
}

.no-results p {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.no-results-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ============= IMAGE EDITOR ============= */

.image-editor-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
}

.image-editor-container {
  background: var(--bg-card);
  border-radius: 16px;
  max-width: 700px;
  width: 100%;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.image-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.image-editor-header h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.image-editor-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  transition: color 0.2s ease;
}

.image-editor-close:hover {
  color: var(--text-primary);
}

.image-editor-canvas-wrapper {
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--bg-secondary);
  overflow: auto;
  flex: 1;
}

.image-editor-canvas {
  max-width: 100%;
  max-height: 100%;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: move;
}

.image-editor-controls {
  padding: 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.control-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  min-width: 80px;
}

.control-buttons {
  display: flex;
  gap: 8px;
}

.control-btn {
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.control-btn:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #000;
}

.brightness-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-hover);
  outline: none;
}

.brightness-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.brightness-slider::-webkit-slider-thumb:hover {
  background: var(--accent-hover);
  transform: scale(1.1);
}

.brightness-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.brightness-slider::-moz-range-thumb:hover {
  background: var(--accent-hover);
  transform: scale(1.1);
}

.brightness-value {
  font-size: 0.875rem;
  color: var(--text-secondary);
  min-width: 50px;
  text-align: right;
}

.image-editor-footer {
  padding: 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.image-editor-footer button {
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-cancel {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.btn-cancel:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-save {
  background: var(--accent-primary);
  border: none;
  color: #000;
}

.btn-save:hover {
  background: var(--accent-hover);
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .image-editor-container {
    max-height: 95vh;
  }

  .control-group {
    flex-wrap: wrap;
  }

  .control-group label {
    min-width: 100%;
  }

  .image-editor-footer {
    padding: 16px;
  }
}

/* ================================================================
   BULK POST SELECTION
   ================================================================ */

/* Full-card transparent overlay — visible only in select mode */
.post-select-overlay {
  display: none;
  position: absolute;
  inset: 0;
  border-radius: 12px;
  z-index: 10;
  cursor: pointer;
  background: transparent;
  transition: background 0.15s ease, border 0.15s ease;
}
body.bulk-select-mode .post-select-overlay {
  display: block;
}
.post-card--selected .post-select-overlay {
  background: rgba(0, 188, 212, 0.12);
  outline: 2px solid #00bcd4;
  outline-offset: -2px;
  border-radius: 12px;
}

/* Checkmark badge in top-right corner of each card */
.post-select-check {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.45);
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #fff;
  pointer-events: none;
}
body.bulk-select-mode .post-select-check {
  display: flex;
}
.post-card--selected .post-select-check {
  background: #00bcd4;
  border-color: #00bcd4;
}

/* Select-mode header button active state */
.select-mode-btn.active {
  color: #00bcd4 !important;
  border-color: #00bcd4 !important;
}

/* ── Bulk action bar (sits above the bottom nav) ─────────────────── */
.bulk-action-bar { display: none; } /* removed — replaced by select-mode header */

/* ── Select-mode header (Telegram/Instagram style) ────────────── */
/* Keep header pinned during select mode — no exceptions */
body.bulk-select-mode .app-header {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 1100 !important;
}

/* Hide normal header content in select mode */
body.bulk-select-mode #headerNormalLeft,
body.bulk-select-mode #headerNormalRight {
  display: none;
}

/* Show select-mode header content */
.select-mode-header {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}
body.bulk-select-mode .select-mode-header {
  display: flex;
}

.sel-cancel-btn {
  background: none;
  border: none;
  color: var(--text-primary, #fff);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
}
.sel-cancel-btn:hover { background: rgba(255,255,255,0.08); }

.sel-count {
  font-size: 0.97rem;
  font-weight: 700;
  color: var(--text-primary, #fff);
  text-align: center;
  flex: 1;
}

.sel-forward-btn {
  background: #00bcd4;
  color: #000;
  border: none;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}
.sel-forward-btn:hover { opacity: 0.88; }
.sel-forward-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ═══════════════════════════════════════════════════════════════
   FORWARD SHEET  (Telegram-style unified bottom sheet)
   ═══════════════════════════════════════════════════════════════ */

.fwd-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 2000;
  opacity: 0; pointer-events: none;
  transition: opacity 0.28s ease;
}
.fwd-overlay.visible { opacity: 1; pointer-events: auto; }

.fwd-sheet {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 2001;
  background: #1a1a2e;
  border-radius: 22px 22px 0 0;
  max-height: 90vh;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 -8px 40px rgba(0,0,0,0.5);
}
.fwd-sheet.open { transform: translateY(0); }

.fwd-sheet-handle {
  width: 40px; height: 4px;
  background: rgba(255,255,255,0.18);
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}
.fwd-sheet-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px 6px;
  flex-shrink: 0;
}
.fwd-sheet-title {
  font-size: 1rem; font-weight: 700;
  color: var(--text-primary, #fff);
}
.fwd-close-btn {
  font-size: 1.4rem; line-height: 1;
  color: rgba(255,255,255,0.5);
  padding: 4px 8px;
}
.fwd-close-btn:hover { color: #fff; }

.fwd-search-wrap {
  display: flex; align-items: center; gap: 8px;
  margin: 6px 14px 8px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 8px 12px;
  flex-shrink: 0;
}
.fwd-search-icon { font-size: 0.9rem; opacity: 0.45; }
.fwd-search-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text-primary, #fff);
  font-size: 0.93rem; font-family: inherit;
}
.fwd-search-input::placeholder { color: rgba(255,255,255,0.3); }

.fwd-media-picker-wrap {
  padding: 4px 14px 8px;
  flex-shrink: 0;
}
.fwd-picker-label {
  font-size: 0.78rem; color: rgba(255,255,255,0.45);
  margin: 0 0 6px;
}
.fwd-media-strip {
  display: flex; gap: 6px; overflow-x: auto;
  padding-bottom: 4px;
}
.fwd-media-cell {
  flex-shrink: 0; width: 60px; height: 60px;
  border-radius: 8px; overflow: hidden;
  cursor: pointer; position: relative;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}
.fwd-media-cell.selected { border-color: #00e5ff; }
.fwd-check {
  position: absolute; top: 3px; right: 3px;
  background: #00e5ff; color: #000;
  border-radius: 50%; width: 17px; height: 17px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 800;
}
.fwd-play-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: rgba(255,255,255,0.8);
  pointer-events: none;
}

.fwd-board-list {
  flex: 1; overflow-y: auto;
  padding: 0 8px;
}
.fwd-board-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}
.fwd-board-item:hover, .fwd-board-item:active {
  background: rgba(255,255,255,0.07);
}
.fwd-board-item.selected {
  background: rgba(0,229,255,0.08);
}
.fwd-board-avatar {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, #0f3460 0%, #1a1a4e 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.08);
}
.fwd-board-name {
  flex: 1; font-size: 0.93rem;
  color: var(--text-primary, #fff);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fwd-board-check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  font-size: 0.75rem; color: #000;
}
.fwd-board-item.selected .fwd-board-check {
  background: #00e5ff; border-color: #00e5ff;
}
.fwd-board-empty {
  padding: 28px 16px; text-align: center;
  color: rgba(255,255,255,0.3); font-size: 0.9rem;
}

.fwd-footer {
  padding: 10px 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex; flex-direction: column; gap: 8px;
  flex-shrink: 0;
  background: #1a1a2e;
}
.fwd-caption {
  width: 100%; box-sizing: border-box;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  color: var(--text-primary, #fff);
  font-size: 0.92rem; font-family: inherit;
  padding: 10px 12px; resize: none; outline: none;
}
.fwd-caption::placeholder { color: rgba(255,255,255,0.3); }
.fwd-caption:focus { border-color: rgba(0,229,255,0.4); }
.fwd-send-btn {
  align-self: flex-end;
  background: linear-gradient(135deg, #00b4d8, #0077b6);
  color: #fff; font-weight: 700; font-size: 0.93rem;
  border: none; border-radius: 12px;
  padding: 10px 22px; cursor: pointer;
  transition: opacity 0.15s, transform 0.12s;
}
.fwd-send-btn:hover { opacity: 0.9; }
.fwd-send-btn:active { transform: scale(0.97); }
.fwd-send-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
/* ========================================
   GLOBAL LAYOUT UTILITIES
======================================== */

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.transition-fast {
  transition: all 0.2s ease;
}

.gap-8 {
  gap: 8px;
}

.gap-12 {
  gap: 12px;
}

.mb-2 {
  margin-bottom: 8px;
}

.mt-4 {
  margin-top: 16px;
}

.hidden-admin-section {
  display: none;
}
/* ================================================================
   ONBOARDING / AUTH UI GLOBALS
   ================================================================ */

/* Prevent onboarding overlays from creating horizontal scroll */
body.auth-guest,
body.auth-user {
  overflow-x: hidden;
}

/* Shared smooth interaction feel */
.transition-fast {
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.16s ease,
    opacity 0.2s ease;
}

/* Shared flex utilities */
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Notification hidden utility */
.notif-hidden {
  display: none !important;
}

/* Prevent fixed overlays from jittering on iOS */
.menu-btn,
.notif-bell-btn,
#onboardingAuthBtn,
.signup-prompt-sheet,
.side-menu,
.menu-overlay {
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  will-change: transform;
}

/* Better tap responsiveness */
button,
a,
.menu-btn,
.membership-card {
  -webkit-tap-highlight-color: transparent;
}

/* Prevent accidental text selection during swipes */
.slider-container,
.slider-track,
.slide-card {
  user-select: none;
  -webkit-user-select: none;
}

/* Tier card selected state */
.membership-card.selected {
  border-color: rgba(255,255,255,0.45);
  transform: scale(0.985);
}

/* Hidden admin section utility */
.hidden-admin-section {
  display: none;
}

/* Safe z-index hierarchy */
.menu-btn {
  z-index: 10020;
}

.notif-bell-btn {
  z-index: 10015;
}

#onboardingAuthBtn {
  z-index: 10010;
}

/* iOS safe-area support */
@supports (padding: max(0px)) {

  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

}