/* ==========================================================================
   TUN Modern Premium Stylesheet (Sleek Dark Cyberpunk & Glassmorphism)
   ========================================================================== */

:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #131b2e;
  --bg-tertiary: #1e293b;
  --bg-glass: rgba(19, 27, 46, 0.72);
  --border-glass: rgba(255, 255, 255, 0.06);
  --border-focus: rgba(56, 189, 248, 0.4);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-blue: #38bdf8;
  --accent-purple: #a855f7;
  --accent-pink: #ec4899;
  --accent-red: #f43f5e;
  --accent-glow: rgba(56, 189, 248, 0.12);
  
  --shadow-premium: 0 16px 48px rgba(0, 0, 0, 0.45);
  --font-family: 'Plus Jakarta Sans', 'Outfit', system-ui, -apple-system, sans-serif;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;

  /* Legacy variables mapped to new theme for compatibility */
  --bg: var(--bg-primary);
  --panel: var(--bg-glass);
  --text: var(--text-primary);
  --muted: var(--text-secondary);
  --line: var(--border-glass);
  --accent: var(--accent-blue);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(circle at top center, rgba(56, 189, 248, 0.12), transparent 45%),
    radial-gradient(circle at 80% 20%, rgba(168, 85, 247, 0.06), transparent 35%),
    var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-family);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
  transition: var(--transition-fast);
}

img {
  display: block;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-touch-callout: none;
}

video {
  -webkit-user-drag: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Custom Scrollbar Styles */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-blue);
}

.page {
  min-height: 100vh;
}

/* ==========================================================================
   Header / Masthead
   ========================================================================== */
.masthead {
  max-width: 936px;
  margin: 0 auto;
  padding: 32px 20px 20px;
}

.masthead-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
}

.masthead-copy {
  min-width: 0;
  max-width: 640px;
}

body[data-page="home"] .masthead {
  max-width: 560px;
}

body.modal-open {
  overflow: hidden;
}

.brand {
  margin: 0 0 8px;
  color: var(--accent-blue);
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-purple) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-link:hover,
.username-link:hover,
.caption-link:hover {
  color: var(--accent-blue);
}

.masthead h1 {
  margin: 0;
  font-size: clamp(24px, 5vw, 36px);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 10px 0 0;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.6;
}

.auth-shell {
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

/* ==========================================================================
   Alert / Toast System
   ========================================================================== */
.alert-layer {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 5000;
  display: grid;
  gap: 12px;
  width: min(380px, calc(100vw - 48px));
  pointer-events: none;
}

.app-alert {
  pointer-events: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 16px 20px;
  border-radius: 14px;
  border: 1px solid rgba(244, 63, 94, 0.2);
  background: rgba(19, 27, 46, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-premium);
  position: relative;
  overflow: hidden;
  animation: slideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.app-alert::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent-red);
}

.app-alert[data-type="info"] {
  border-color: rgba(56, 189, 248, 0.2);
}

.app-alert[data-type="info"]::before {
  background: var(--accent-blue);
}

.app-alert-copy {
  min-width: 0;
}

.app-alert-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.app-alert-text {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.app-alert-close {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: var(--transition-fast);
}

.app-alert-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* Alert Timer Progress Bar */
.app-alert-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2.5px;
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
}

.app-alert-progress-bar {
  height: 100%;
  width: 100%;
  background: var(--accent-red);
  transform-origin: left;
  animation: shrink 5s linear forwards;
}

.app-alert[data-type="info"] .app-alert-progress-bar {
  background: var(--accent-blue);
}

@keyframes shrink {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

@keyframes slideIn {
  from {
    transform: translateY(24px) scale(0.95);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  to {
    transform: translateY(-20px) scale(0.95);
    opacity: 0;
  }
}

/* ==========================================================================
   Auth Widget & Panels
   ========================================================================== */
.auth-widget {
  position: relative;
  width: max-content;
  max-width: 100%;
}

.auth-quick-actions,
.auth-profile {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.auth-text-button,
.auth-primary-button,
.auth-avatar-trigger,
.auth-menu-item {
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
}

.auth-text-button,
.auth-primary-button {
  min-width: 80px;
  height: 40px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition-smooth);
}

.auth-text-button {
  color: var(--text-secondary);
}

.auth-text-button:hover,
.auth-text-button.active {
  color: var(--text-primary);
}

.auth-primary-button {
  background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-purple) 100%);
  color: #fff;
  padding: 0 16px;
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.25);
}

.auth-primary-button:hover {
  transform: translateY(-1.5px);
  box-shadow: 0 12px 32px rgba(139, 92, 246, 0.4);
}

.auth-primary-button:active {
  transform: translateY(0);
}

.auth-profile-name {
  max-width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.auth-avatar-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
}

.auth-avatar-trigger:hover .auth-avatar {
  border-color: var(--accent-blue);
  box-shadow: 0 0 12px var(--border-focus);
}

.auth-avatar {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent-red) 0%, var(--accent-purple) 100%);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  border: 2px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  transition: var(--transition-smooth);
}

.auth-caret {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--text-muted);
  transition: var(--transition-fast);
}

.auth-avatar-trigger:hover .auth-caret {
  border-top-color: var(--text-primary);
}

.auth-popover {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  z-index: 30;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.auth-popover-form {
  width: min(360px, calc(100vw - 32px));
}

.auth-card-form {
  padding: 20px;
  border-radius: 18px;
}

.auth-menu {
  min-width: 180px;
  padding: 8px;
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  background: rgba(19, 27, 46, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-premium);
  display: grid;
  gap: 4px;
}

.auth-menu-item {
  width: 100%;
  min-height: 40px;
  border-radius: 10px;
  padding: 0 14px;
  text-align: left;
  color: var(--text-secondary);
  font-size: 14px;
  display: flex;
  align-items: center;
  transition: var(--transition-fast);
}

.auth-menu-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.auth-menu-item-danger {
  color: #f43f5e;
}

.auth-menu-item-danger:hover {
  background: rgba(244, 63, 94, 0.1);
  color: #f43f5e;
}

.auth-inline-message {
  margin: 10px 2px 0;
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
}

.auth-card {
  background: rgba(19, 27, 46, 0.88);
  border: 1px solid var(--border-glass);
  border-radius: 18px;
  padding: 20px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-premium);
}

.auth-segment,
.auth-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  background: rgba(15, 23, 42, 0.4);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border-glass);
}

.auth-actions {
  grid-template-columns: 1fr;
  background: transparent;
  padding: 0;
  border: 0;
}

.auth-segment-button,
.auth-ghost,
.auth-submit {
  height: 36px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.auth-segment-button:hover {
  color: var(--text-primary);
}

.auth-segment-button.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.auth-submit {
  background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-purple) 100%);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(139, 92, 246, 0.2);
}

.auth-submit:hover {
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.35);
}

.auth-submit[disabled] {
  opacity: 0.65;
  cursor: wait;
}

.auth-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.auth-form.compact {
  margin-top: 14px;
}

.auth-input {
  width: 100%;
  height: 52px;
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 0 16px;
  font-size: 15px;
  background: rgba(11, 15, 25, 0.6);
  color: var(--text-primary);
  transition: var(--transition-smooth);
}

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

.auth-input:focus {
  outline: none;
  background: rgba(11, 15, 25, 0.85);
  border-color: var(--accent-blue);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.15);
}

.auth-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-glass);
}

.auth-user-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.auth-user-copy strong {
  font-size: 14px;
  color: var(--text-primary);
}

.auth-user-copy span,
.auth-meta,
.auth-message {
  font-size: 12px;
  color: var(--text-secondary);
}

.auth-meta,
.auth-message {
  margin: 10px 0 0;
}

.auth-submit {
  width: 100%;
  height: 48px;
  border-radius: 12px;
  font-size: 16px;
}

/* ==========================================================================
   Timeline / Stream & Cards
   ========================================================================== */
.timeline-shell {
  max-width: 936px;
  margin: 0 auto;
  padding: 0 20px 48px;
}

.timeline {
  display: grid;
  gap: 24px;
  max-width: 520px;
  margin: 0 auto;
}

.status-copy {
  margin: 0;
  color: var(--text-secondary);
  padding: 24px 4px;
  text-align: center;
  font-size: 15px;
}

.skeleton-card,
.post-card,
.profile-header-card {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: 18px;
  box-shadow: var(--shadow-premium);
  overflow: hidden;
  transition: var(--transition-smooth);
}

.post-card:hover {
  transform: translateY(-4px);
  border-color: rgba(56, 189, 248, 0.2);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), 0 0 24px rgba(56, 189, 248, 0.05);
}

.skeleton-card {
  padding: 20px;
  max-width: 520px;
  margin: 0 auto;
}

.skeleton {
  background: linear-gradient(90deg, #131b2e 0%, #1e293b 45%, #131b2e 100%);
  background-size: 220% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 8px;
}

.skeleton-header {
  height: 32px;
  width: 45%;
  margin-bottom: 16px;
}

.skeleton-media {
  height: 520px;
  margin-bottom: 16px;
  border-radius: 12px;
}

.skeleton-line {
  height: 12px;
  margin-bottom: 10px;
}

.skeleton-line.short {
  width: 65%;
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

/* Post Card Layout & Micro Details */
.post-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
}

.identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.identity-link {
  display: block;
  flex: 0 0 auto;
}

.avatar,
.profile-avatar {
  border-radius: 999px;
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  object-fit: cover;
  background: var(--bg-tertiary);
  transition: var(--transition-smooth);
}

.avatar {
  width: 38px;
  height: 38px;
}

.avatar:hover {
  border-color: var(--accent-blue);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
}

.identity-copy {
  min-width: 0;
}

.identity-line,
.identity-subline {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.identity-subline {
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 12px;
}

.username,
.username-link {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
}

.display-name,
.timestamp,
.location {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.badge {
  color: rgba(255, 255, 255, 0.15);
  font-size: 10px;
}

/* ==========================================================================
   Smooth Slide Carousel system
   ========================================================================== */
.media-frame {
  position: relative;
  background: #080b12;
  aspect-ratio: 4 / 5.2;
  overflow: hidden;
  border-radius: 12px;
  margin: 0 16px;
  border: 1px solid var(--border-glass);
}

/* Carousel Track & Slides for transition animations */
.media-track {
  display: flex;
  height: 100%;
  width: 100%;
  transition: transform 0.38s cubic-bezier(0.25, 1, 0.5, 1);
  will-change: transform;
}

.media-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.hero-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Arrow controls with glass backdrop */
.nav-arrow {
  position: absolute;
  top: 50%;
  z-index: 3;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(19, 27, 46, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.nav-arrow.left {
  left: 12px;
}

.nav-arrow.right {
  right: 12px;
}

.nav-arrow:hover {
  background: rgba(19, 27, 46, 0.85);
  border-color: var(--accent-blue);
  transform: translateY(-50%) scale(1.08);
}

.nav-arrow:active {
  transform: translateY(-50%) scale(0.94);
}

.media-counter {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  padding: 5px 10px;
  border-radius: 20px;
  background: rgba(11, 15, 25, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.media-chip-row {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 2;
  display: flex;
  gap: 8px;
}

.media-chip,
.profile-tile-chip {
  padding: 5px 9px;
  border-radius: 8px;
  background: rgba(11, 15, 25, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.pager {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 3;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(11, 15, 25, 0.5);
  padding: 5px 8px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.dot {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.4);
  border: 0;
  padding: 0;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.dot.active {
  background: var(--accent-blue);
  width: 14px;
  box-shadow: 0 0 6px var(--accent-blue);
}

.post-body {
  padding: 14px 18px 18px;
}

.caption {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.caption-link {
  margin-right: 6px;
  font-weight: 700;
  color: var(--accent-blue);
}

.post-meta {
  margin: 8px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ==========================================================================
   Profile Page
   ========================================================================== */
.profile-page {
  display: grid;
  gap: 24px;
}

.profile-header-card {
  padding: 32px;
}

.profile-hero {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 32px;
  align-items: center;
}

.profile-avatar {
  width: 160px;
  height: 160px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.profile-avatar:hover {
  border-color: var(--accent-blue);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.3);
}

.profile-copy h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 36px);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.profile-display-name {
  margin: 8px 0 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}

.profile-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin: 18px 0 0;
  font-size: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-glass);
}

.profile-stats span strong {
  color: var(--text-primary);
  font-size: 16px;
}

.profile-bio {
  margin-top: 16px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

.profile-bio p {
  margin: 0 0 6px;
}

.profile-bio p:last-child {
  margin-bottom: 0;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.profile-tile {
  position: relative;
  background: var(--bg-secondary);
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition-smooth);
  border: 1px solid var(--border-glass);
}

.profile-tile:hover {
  transform: scale(1.025);
  border-color: rgba(56, 189, 248, 0.3);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4), 0 0 16px rgba(56, 189, 248, 0.08);
}

.profile-tile-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.profile-tile:hover .profile-tile-image {
  transform: scale(1.04);
}

.profile-tile-overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: 16px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(11, 15, 25, 0.88) 100%);
  color: #fff;
  opacity: 0;
  transition: var(--transition-smooth);
}

.profile-tile:hover .profile-tile-overlay {
  opacity: 1;
}

.profile-tile-overlay p {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-primary);
}

/* Pagination */
.profile-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.page-numbers {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.page-link,
.page-number,
.page-ellipsis {
  min-width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--border-glass);
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: var(--transition-fast);
}

.page-link:hover,
.page-number:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--accent-blue);
}

.page-number.active {
  background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-purple) 100%);
  border: 0;
  color: #fff;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
}

.page-link.disabled {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.02);
  cursor: not-allowed;
  pointer-events: none;
}

/* ==========================================================================
   Elastic Modal Viewport
   ========================================================================== */
.post-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 4000;
  background: rgba(8, 11, 20, 0.85);
  display: grid;
  place-items: center;
  padding: 24px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.post-modal {
  width: min(960px, calc(100vw - 48px));
  height: min(760px, calc(100vh - 48px));
  background: rgba(19, 27, 46, 0.94);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.75fr);
  position: relative;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.65);
  animation: scaleUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.post-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 4;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(11, 15, 25, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.post-modal-close:hover {
  background: rgba(11, 15, 25, 0.95);
  border-color: var(--accent-blue);
  transform: rotate(90deg) scale(1.05);
}

.post-modal-media {
  position: relative;
  background: #080a10;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.post-modal-media .hero-media {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #080a10;
}

.post-modal-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  background: rgba(19, 27, 46, 0.4);
  border-left: 1px solid var(--border-glass);
}

.post-modal-author {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-glass);
}

.post-modal-copy {
  padding: 20px 24px 24px;
  overflow: auto;
}

.post-modal-caption {
  margin: 0 0 20px;
  font-size: 15px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary);
}

/* ==========================================================================
   Media Queries & Responsiveness
   ========================================================================== */
@media (min-width: 980px) {
  .timeline-shell {
    padding-bottom: 72px;
  }
  .timeline {
    gap: 28px;
  }
}

@media (max-width: 720px) {
  .masthead {
    padding: 20px 16px 12px;
  }

  .masthead-top {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .auth-shell {
    justify-content: flex-end;
    padding-top: 0;
  }

  .auth-widget,
  .auth-popover-form {
    width: 100%;
  }

  .alert-layer {
    top: 16px;
    right: 16px;
    left: 16px;
    width: auto;
  }

  .auth-quick-actions,
  .auth-profile {
    justify-content: space-between;
  }

  .auth-popover {
    left: 0;
    right: 0;
  }

  .timeline-shell {
    padding: 0 0 28px;
  }

  .timeline {
    max-width: none;
  }

  .skeleton-card,
  .post-card,
  .profile-header-card {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    box-shadow: none;
    background: rgba(19, 27, 46, 0.4);
  }

  .post-card:hover {
    transform: none;
    box-shadow: none;
  }

  .media-frame {
    aspect-ratio: 1 / 1.15;
    border-radius: 0;
    margin: 0;
    border-left: 0;
    border-right: 0;
  }

  .profile-header-card {
    padding: 24px 16px;
  }

  .profile-hero {
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 20px;
  }

  .profile-avatar {
    width: 88px;
    height: 88px;
  }

  .profile-grid {
    gap: 4px;
  }

  .post-modal-backdrop {
    padding: 12px;
  }

  .post-modal {
    width: min(960px, calc(100vw - 24px));
    height: min(760px, calc(100vh - 24px));
    border-radius: 16px;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(300px, 50vh) auto;
  }

  .post-modal-media {
    min-height: 0;
  }

  .post-modal-panel {
    min-height: 0;
    border-left: 0;
    border-top: 1px solid var(--border-glass);
  }
}

/* Home Page Infinite Scroll Loader */
.home-loader-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px 0 48px;
  width: 100%;
}

.home-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ==========================================================================
   Asset Download System Styles
   ========================================================================== */
.post-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-glass);
}

.btn-download-assets {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-download-assets:hover {
  background: rgba(56, 189, 248, 0.08);
  border-color: var(--accent-blue);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.btn-download-assets:active {
  transform: translateY(0);
}

.btn-download-assets svg {
  transition: transform 0.2s ease;
}

.btn-download-assets:hover svg {
  transform: translateY(1px);
}

/* Material Selection Modal Backdrop */
.download-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(8, 11, 20, 0.82);
  display: grid;
  place-items: center;
  padding: 24px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Selection Modal Window */
.download-modal {
  width: min(560px, calc(100vw - 48px));
  max-height: min(680px, calc(100vh - 48px));
  background: rgba(19, 27, 46, 0.93);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  padding: 28px;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 16px;
  position: relative;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.7);
  animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.download-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  font-size: 20px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.download-modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  transform: rotate(90deg);
}

.download-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.download-modal-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Toolbar (Select All / None) */
.download-modal-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.download-modal-toolbar button {
  background: none;
  border: none;
  color: var(--accent-blue);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-size: 13px;
  transition: opacity 0.2s;
}

.download-modal-toolbar button:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.toolbar-divider {
  color: rgba(255, 255, 255, 0.15);
  font-size: 11px;
}

/* Material Thumbnails Grid */
.download-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  overflow-y: auto;
  max-height: 280px;
  padding-right: 4px;
}

/* Scrollbar for grid */
.download-grid::-webkit-scrollbar {
  width: 4px;
}
.download-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
}

/* Asset Selection Card */
.asset-select-card {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid transparent;
  background: #080b12;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.asset-select-card:hover {
  transform: scale(1.02);
}

.asset-select-card.selected {
  border-color: var(--accent-blue);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
}

.asset-thumbnail-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
}

.asset-thumbnail-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.2s ease;
}

.asset-select-card:not(.selected) .asset-thumbnail-media {
  opacity: 0.65;
}

/* Checkbox Indicator Badge */
.asset-checkbox-overlay {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
}

.custom-checkbox {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 1.5px solid rgba(255, 255, 255, 0.5);
  background: rgba(11, 15, 25, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.custom-checkbox.checked {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
}

.custom-checkbox.checked::after {
  content: '';
  width: 5px;
  height: 9px;
  border: 2px solid white;
  border-left: 0;
  border-top: 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}

.video-duration-chip {
  position: absolute;
  left: 6px;
  bottom: 6px;
  background: rgba(11, 15, 25, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 8px;
  font-weight: 700;
  color: white;
}

/* Bottom Actions Row */
.download-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

.btn-download-cancel {
  height: 44px;
  padding: 0 20px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-download-cancel:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.btn-download-confirm {
  height: 44px;
  padding: 0 24px;
  border-radius: 12px;
  border: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-download-confirm[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.08) !important;
  color: rgba(255, 255, 255, 0.3) !important;
  box-shadow: none !important;
}

/* Responsive Overrides */
@media (max-width: 720px) {
  .post-meta-row {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-download-assets {
    height: 40px;
    font-size: 13px;
    width: 100%;
    margin-top: 4px;
  }
}

@media (max-width: 480px) {
  .download-modal-backdrop {
    padding: 12px;
  }
  
  .download-modal {
    width: 100%;
    padding: 20px;
    gap: 12px;
  }
  
  .download-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    max-height: 220px;
  }
  
  .download-modal-actions {
    flex-direction: column-reverse;
  }
  
  .btn-download-cancel,
  .btn-download-confirm {
    width: 100%;
  }
}