:root {
  --bg-primary: #090d16;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(99, 102, 241, 0.5);
  
  --accent-indigo: #6366f1;
  --accent-violet: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-emerald: #10b981;
  --accent-danger: #ef4444;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 6px;

  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 10px 24px -5px rgba(99, 102, 241, 0.3);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 10% 10%, rgba(99, 102, 241, 0.1) 0px, transparent 40%),
    radial-gradient(at 90% 90%, rgba(139, 92, 246, 0.08) 0px, transparent 40%);
  color: var(--text-primary);
  min-height: 100vh;
  padding: 16px 20px;
}

.app-container {
  max-width: 1600px;
  margin: 0 auto;
}

/* Login/Signup Modal Overlay */
.login-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(9, 13, 22, 0.95);
  backdrop-filter: blur(20px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

/* Auth Tabs */
.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.auth-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 10px 0;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.auth-tab-btn.active {
  color: #ffffff;
  border-bottom-color: var(--accent-indigo);
}

.login-header {
  text-align: center;
  margin-bottom: 16px;
}

.login-header .logo-icon {
  font-size: 2.2rem;
  margin: 0 auto 10px;
}

.login-header h2 {
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.login-header p {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

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

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}

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

.logo-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-violet));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.header-brand h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-badge {
  background: rgba(255, 255, 255, 0.05);
  color: #c7d2fe;
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Storage 100MB Quota Badge & Progress Bar */
.storage-badge-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 5px 10px;
  border-radius: var(--radius-md);
}

.storage-usage-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: #a5b4fc;
}

.storage-progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.storage-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-indigo), var(--accent-emerald));
  border-radius: 999px;
  transition: width 0.3s ease;
}

.storage-progress-fill.warning {
  background: linear-gradient(90deg, #f59e0b, #ef4444);
}

.stats-badge {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* URL Saver Section */
.url-saver-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
  backdrop-filter: blur(16px);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  margin-bottom: 20px;
  box-shadow: 0 8px 24px -8px rgba(99, 102, 241, 0.2);
}

.url-saver-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.url-saver-header h2 {
  font-size: 0.92rem;
  font-weight: 700;
  color: #f1f5f9;
}

.url-input-group {
  display: flex;
  gap: 10px;
}

.url-input {
  flex-grow: 1;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: #ffffff;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

.url-input:focus {
  border-color: var(--accent-indigo);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.url-status {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  word-break: break-word;
}

.url-status.success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.url-status.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.url-status.loading {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #60a5fa;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-violet));
  color: white;
  box-shadow: 0 3px 10px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.btn-lg {
  padding: 10px 20px;
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Grid Layout - Uniform Heights */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
  align-items: stretch;
}

/* Post Card - Perfectly Balanced & Uniform Dimensions */
.post-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: var(--shadow-card);
}

.post-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-hover);
}

.card-header {
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  height: 44px;
}

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

.username-tag {
  font-weight: 700;
  font-size: 0.88rem;
  color: #c7d2fe;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.icon-btn.danger:hover {
  color: var(--accent-danger);
  background: rgba(239, 68, 68, 0.15);
}

/* Card Body - Clean Uniform Height & Multi-line Truncation */
.card-body {
  padding: 10px 14px;
  font-size: 0.85rem;
  line-height: 1.45;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-word;
  height: 68px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* Media Display - UNIFIED 1:1 / 4:3 Aspect Ratio */
.media-container {
  position: relative;
  background: #050811;
  width: 100%;
  height: 240px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-image {
  width: 100%;
  height: 240px;
  object-fit: cover;
  display: block;
}

.media-video {
  width: 100%;
  height: 240px;
  outline: none;
  object-fit: cover;
}

/* Carousel */
.carousel-wrapper {
  position: relative;
  width: 100%;
  height: 240px;
}

.carousel-slide {
  display: none;
  height: 240px;
}

.carousel-slide.active {
  display: block;
}

.carousel-controls {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  display: flex;
  justify-content: space-between;
  padding: 0 8px;
  pointer-events: none;
  z-index: 10;
}

.carousel-btn {
  pointer-events: auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.carousel-btn:hover {
  background: rgba(0, 0, 0, 0.9);
}

.carousel-dots {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  background: rgba(0, 0, 0, 0.6);
  padding: 3px 8px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
  z-index: 10;
}

.dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transition: background 0.2s, transform 0.2s;
}

.dot.active {
  background: var(--accent-indigo);
  transform: scale(1.3);
}

.card-footer {
  padding: 8px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.73rem;
  color: var(--text-muted);
  height: 36px;
  margin-top: auto;
}

.storage-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-emerald);
  font-weight: 600;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 500px;
  margin: 40px auto;
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 1.1rem;
  margin-bottom: 6px;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* Mobile Breakpoints (iPhone / Android) */
@media (max-width: 640px) {
  body {
    padding: 10px;
  }
  
  .app-header {
    padding: 10px 14px;
  }
  
  .subtitle {
    display: none;
  }

  .user-badge {
    max-width: 110px;
  }
  
  .url-saver-card {
    padding: 12px 14px;
  }
  
  .url-input-group {
    flex-direction: column;
  }
  
  .btn-lg {
    width: 100%;
    padding: 12px;
  }
  
  .cards-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  
  .media-container, .media-image, .media-video, .carousel-wrapper, .carousel-slide {
    height: 220px;
  }
}
