/* CSS Variables */
:root {
  --primary-color: #5b8be8;
  --primary-dark: #4a7bd8;
  --background-dark: #1a1a2e;
  --card-bg: rgba(255, 255, 255, 0.95);
  --card-bg-dark: rgba(30, 30, 50, 0.9);
  --text-primary: #1a1a2e;
  --text-secondary: #666;
  --text-muted: #999;
  --border-color: rgba(0, 0, 0, 0.08);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.2);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --safe-area-inset-top: env(safe-area-inset-top, 0px);
  --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--background-dark);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Background */
.background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 1;
  transition: opacity 0.8s ease-in-out;
}

.background.fade-out {
  opacity: 0;
}

.background-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.3) 0%,
    rgba(0, 0, 0, 0.1) 30%,
    rgba(0, 0, 0, 0.2) 70%,
    rgba(0, 0, 0, 0.5) 100%
  );
}

/* App Container */
.app-container {
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(var(--safe-area-inset-top) + 16px) 16px calc(var(--safe-area-inset-bottom) + 16px);
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
}

/* Search Section - Fixed at top */
.search-section {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: calc(var(--safe-area-inset-top) + 16px) 16px 16px;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.4) 0%,
    rgba(0, 0, 0, 0.2) 70%,
    transparent 100%
  );
  max-width: 600px;
  margin: 0 auto;
}

/* Spacer for fixed search section */
.search-spacer {
  height: 90px;
  flex-shrink: 0;
}

.search-container {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  padding: 8px 12px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.search-engine-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: #f5f5f5;
  border-radius: 50%;
  cursor: pointer;
  transition: transform var(--transition-fast), background var(--transition-fast);
  flex-shrink: 0;
}

.search-engine-btn:active {
  transform: scale(0.95);
  background: #e8e8e8;
}

.search-engine-btn img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.search-input {
  flex: 1;
  height: 40px;
  border: none;
  background: transparent;
  font-size: 16px;
  font-family: inherit;
  color: var(--text-primary);
  outline: none;
}

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

.voice-search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 50%;
  transition: color var(--transition-fast), background var(--transition-fast);
  flex-shrink: 0;
}

.voice-search-btn:active {
  background: #f0f0f0;
  color: var(--primary-color);
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 101;
  max-height: 400px;
  overflow-y: auto;
  animation: slideDown 200ms ease;
}

.autocomplete-section {
  border-bottom: 1px solid var(--border-color);
}

.autocomplete-section:last-child {
  border-bottom: none;
}

.autocomplete-section:empty {
  display: none;
}

.autocomplete-section-label {
  padding: 10px 16px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.autocomplete-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--transition-fast);
  text-decoration: none;
  color: inherit;
}

.autocomplete-item:hover,
.autocomplete-item:active,
.autocomplete-item.selected {
  background: rgba(91, 139, 232, 0.1);
}

.autocomplete-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.autocomplete-icon img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.autocomplete-icon svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.autocomplete-icon.history-icon {
  background: transparent;
}

.autocomplete-icon.domain-icon {
  background: white;
  border: 1px solid var(--border-color);
}

.autocomplete-content {
  flex: 1;
  min-width: 0;
}

.autocomplete-text {
  font-size: 15px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.autocomplete-text mark {
  background: transparent;
  color: var(--primary-color);
  font-weight: 600;
}

.autocomplete-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.autocomplete-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 50%;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition-fast), background var(--transition-fast);
}

.autocomplete-item:hover .autocomplete-action {
  opacity: 1;
}

.autocomplete-action:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}

.autocomplete-action.delete:hover {
  color: #e53935;
}

/* Search Engine Dropdown */
.search-engine-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 100;
  animation: slideDown 200ms ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.dropdown-item:active,
.dropdown-item.active {
  background: rgba(91, 139, 232, 0.1);
}

.dropdown-item img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.dropdown-item span {
  font-size: 15px;
  font-weight: 500;
}

.dropdown-item.active span {
  color: var(--primary-color);
}

/* Section Headers */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 4px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: white;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  cursor: pointer;
  color: white;
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.add-btn:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.3);
}

/* Favorites Carousel */
.favorites-section {
  padding: 0;
}

.favorites-carousel-wrapper {
  margin: 0 -16px;
  padding: 0 0 0 16px;
  overflow: hidden;
  position: relative;
}

.favorites-carousel {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding: 8px 0 16px 0;
  scroll-behavior: smooth;
  /* Always show scrollbar */
  scrollbar-width: auto;
  scrollbar-color: rgba(255, 255, 255, 0.4) rgba(255, 255, 255, 0.1);
}

/* Custom scrollbar for webkit browsers */
.favorites-carousel::-webkit-scrollbar {
  height: 8px;
  display: block;
}

.favorites-carousel::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  margin: 0 16px;
}

.favorites-carousel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.4);
  border-radius: 10px;
}

.favorites-carousel::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.6);
}


.favorite-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 70px;
  scroll-snap-align: start;
  text-decoration: none;
  cursor: pointer;
  -webkit-touch-callout: none;
  user-select: none;
  flex-shrink: 0;
}

.favorite-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  /* Glassmorphism effect */
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  overflow: hidden;
}

.favorite-icon:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.25);
}

.favorite-icon img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.favorite-name {
  font-size: 12px;
  font-weight: 500;
  color: white;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Super App Services Grid */
.services-section {
  padding: 0;
}

.services-grid-wrapper {
  /* No background - transparent */
}

.services-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Categories 4x2 Grid */
.services-categories {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px 12px;
}

.service-category,
.service-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  cursor: pointer;
  -webkit-touch-callout: none;
  user-select: none;
  transition: transform var(--transition-fast);
}

.service-category:active,
.service-item:active {
  transform: scale(0.95);
}

.service-category.expanded .service-icon {
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}

.service-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  /* Glassmorphism effect - same as favorites */
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  overflow: hidden;
}

.service-icon:hover {
  background: rgba(255, 255, 255, 0.25);
}

.service-icon svg {
  width: 28px;
  height: 28px;
}

.service-name {
  font-size: 12px;
  font-weight: 500;
  color: white;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Expanded Services Panel */
.services-expanded {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  animation: slideDown 200ms ease;
}

.services-expanded-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.services-expanded-title {
  font-size: 16px;
  font-weight: 600;
  color: white;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  user-select: none;
  -webkit-touch-callout: none;
}

.services-expanded-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  cursor: pointer;
  color: white;
  transition: background var(--transition-fast);
}

.services-expanded-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

.services-expanded-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px 12px;
}

.services-expanded .service-icon {
  width: 52px;
  height: 52px;
}

/* Feed Section */
.feed-section {
  flex: 1;
}

.feed-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.feed-item {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: transform var(--transition-fast);
  text-decoration: none;
  color: inherit;
  display: block;
}

.feed-item:active {
  transform: scale(0.98);
}

.feed-image {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: #f0f0f0;
}

.feed-content {
  padding: 14px 16px;
}

.feed-source {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.feed-source-icon {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: #e0e0e0;
}

.feed-source-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.feed-source-time {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
}

.feed-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.feed-description {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Social Post Styles */
.social-post {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.social-post-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
}

.social-post-user {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.social-post-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.social-post-user-info {
  flex: 1;
  min-width: 0;
}

.social-post-user-name {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.social-post-verified {
  color: var(--primary-color);
  font-size: 12px;
  font-weight: 700;
}

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

.social-post-content {
  padding: 0 16px;
}

.social-post-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.social-post-image {
  width: 100%;
  height: auto;
  max-height: 400px;
  object-fit: cover;
}

.social-post-video {
  position: relative;
  width: 100%;
  max-height: 300px;
}

.social-post-thumbnail {
  width: 100%;
  height: auto;
  max-height: 300px;
  object-fit: cover;
}

.social-post-duration {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.social-post-article {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.social-post-article-image {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.social-post-article-content {
  flex: 1;
  min-width: 0;
}

.social-post-article-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.social-post-article-description {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.social-post-article-source {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.social-post-actions {
  display: flex;
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
}

.social-post-action {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-md);
  font-size: 13px;
  transition: all var(--transition-fast);
  flex: 1;
  justify-content: center;
}

.social-post-action:hover {
  background: rgba(91, 139, 232, 0.1);
  color: var(--primary-color);
}

.social-post-action.liked {
  color: #e53935;
}

.social-post-action svg {
  width: 18px;
  height: 18px;
}

.social-post-action span {
  font-weight: 500;
}

/* Kahf Ad Card */
.kahf-ad {
  background: linear-gradient(135deg, #5b8be8 0%, #4a7bd8 100%);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: transform var(--transition-fast);
  text-decoration: none;
  display: block;
}

.kahf-ad:active {
  transform: scale(0.98);
}

.kahf-ad-content {
  padding: 20px;
  color: white;
}

.kahf-ad-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 12px;
}

.kahf-ad-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.3;
}

.kahf-ad-description {
  font-size: 14px;
  opacity: 0.9;
  line-height: 1.5;
  margin-bottom: 16px;
}

.kahf-ad-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: white;
  color: var(--primary-color);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-xl);
  transition: transform var(--transition-fast);
}

.kahf-ad-cta:active {
  transform: scale(0.95);
}

.kahf-ad-image {
  width: 100%;
  height: 140px;
  object-fit: cover;
}

/* Feed Loader */
.feed-loader {
  display: flex;
  justify-content: center;
  padding: 24px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  animation: fadeIn 200ms ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  position: relative;
  background: white;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 24px;
  padding-bottom: calc(24px + var(--safe-area-inset-bottom));
  width: 100%;
  max-width: 500px;
  animation: slideUp 300ms ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-content h3 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 20px;
  text-align: center;
}

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

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

.form-group input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 16px;
  font-size: 16px;
  font-family: inherit;
  transition: border-color var(--transition-fast);
}

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

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

.btn-cancel,
.btn-primary {
  flex: 1;
  height: 48px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.btn-cancel {
  background: #f0f0f0;
  color: var(--text-primary);
}

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

.btn-cancel:active,
.btn-primary:active {
  transform: scale(0.98);
}

/* Context Menu */
.context-menu {
  position: fixed;
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 1001;
  min-width: 160px;
  animation: scaleIn 150ms ease;
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  background: none;
  font-size: 15px;
  font-family: inherit;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition-fast);
  text-align: left;
}

.context-menu-item:active {
  background: #f5f5f5;
}

.context-menu-item[data-action="delete"] {
  color: #e53935;
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Desktop Adjustments */
@media (min-width: 768px) {
  .app-container {
    padding: 32px 24px;
  }

  .feed-image {
    height: 220px;
  }

  .modal-content {
    border-radius: var(--radius-xl);
    margin-bottom: 40px;
  }
}

/* Landscape adjustments */
@media (max-height: 500px) and (orientation: landscape) {
  .app-container {
    gap: 16px;
  }

  .search-section {
    padding-top: 8px;
  }

  .favorites-carousel {
    gap: 12px;
  }

  .favorite-icon {
    width: 48px;
    height: 48px;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --card-bg: rgba(40, 40, 60, 0.95);
    --text-primary: #fff;
    --text-secondary: #bbb;
    --text-muted: #888;
    --border-color: rgba(255, 255, 255, 0.1);
  }

  .search-engine-btn {
    background: #3a3a4a;
  }

  .search-engine-btn:active {
    background: #4a4a5a;
  }

  .dropdown-item:active,
  .dropdown-item.active {
    background: rgba(91, 139, 232, 0.2);
  }

  .btn-cancel {
    background: #3a3a4a;
    color: #fff;
  }

  .modal-content,
  .context-menu {
    background: #2a2a3a;
  }

  .form-group input {
    background: #3a3a4a;
    border-color: rgba(255, 255, 255, 0.1);
    color: white;
  }

  .context-menu-item:active {
    background: #3a3a4a;
  }
}

/* Scroll to Top Button */
.scroll-to-top {
  position: fixed;
  bottom: calc(24px + var(--safe-area-inset-bottom));
  right: 16px;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 99;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: opacity 300ms ease, visibility 300ms ease, transform 300ms ease, background 200ms ease;
}

.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-to-top:hover {
  background: rgba(255, 255, 255, 0.3);
}

.scroll-to-top:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.4);
}

.scroll-to-top svg {
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 4px rgba(0, 0, 0, 0.3));
}

/* Post Composer Bottom Sheet */
.post-composer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-lg);
  z-index: 1002;
  transform: translateY(100%);
  transition: transform var(--transition-normal), border-radius var(--transition-normal);
  padding-bottom: calc(var(--safe-area-inset-bottom));
  cursor: pointer;
}

.post-composer:not(.hidden) {
  transform: translateY(0);
}

.post-composer.expanded {
  border-radius: var(--radius-xl) var(--radius-xl) var(--radius-xl) var(--radius-xl);
  cursor: default;
}

/* Compact single-line layout */
.post-composer-compact {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;  /* Reduced padding from 12px 20px to 8px 16px */
  min-height: 40px;    /* Reduced height from 44px to 40px */
}

.post-composer-input-compact {
  flex: 1;
  background: transparent;
  border: none;
  resize: none;
  outline: none;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  min-height: 24px;    /* Increased to 24px for better touch target */
  max-height: 24px;
  overflow: hidden;
  padding: 0;
  margin: 0;
}

.post-composer-input-compact::placeholder {
  color: var(--text-muted);
}

.post-composer-actions-compact {
  flex-shrink: 0;
}

.composer-btn-submit-compact {
  padding: 6px 14px;  /* Slightly reduced padding */
  border: none;
  border-radius: var(--radius-md);
  background: var(--primary-color);
  color: white;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-width: 60px;
  margin: 0;
}

.composer-btn-submit-compact:hover:not(:disabled) {
  background: var(--primary-dark);
}

.composer-btn-submit-compact:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Show/hide layouts based on state */
.post-composer:not(.expanded) .post-composer-compact {
  display: flex;
}

.post-composer:not(.expanded) .post-composer-content {
  display: none;
}

.post-composer.expanded .post-composer-compact {
  display: none;
}

.post-composer.expanded .post-composer-content {
  display: block;
}


.post-composer-content {
  padding: 0 20px 20px;
}

.post-composer-input-wrapper {
  position: relative;
  margin-bottom: 16px;
}

.post-composer-input {
  width: 100%;
  background: transparent;
  border: none;
  resize: none;
  outline: none;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  min-height: 24px;
  max-height: 96px; /* 4 lines max */
  overflow-y: auto;
}

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

.post-composer-char-count {
  position: absolute;
  bottom: -20px;
  right: 0;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.post-composer-media {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.composer-media-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border: none;
  background: #f8f9fa;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex: 1;
  min-width: 0;
  color: var(--text-secondary);
}

.composer-media-btn:hover {
  background: #e9ecef;
  color: var(--primary-color);
  transform: translateY(-1px);
}

.composer-media-btn:active {
  transform: translateY(0);
}

.composer-media-btn svg {
  width: 24px;
  height: 24px;
}

.composer-media-btn span {
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.post-composer-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.composer-btn-cancel,
.composer-btn-submit {
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-width: 80px;
}

.composer-btn-cancel {
  background: #f0f0f0;
  color: var(--text-primary);
}

.composer-btn-cancel:hover {
  background: #e0e0e0;
}

.composer-btn-submit {
  background: var(--primary-color);
  color: white;
}

.composer-btn-submit:hover:not(:disabled) {
  background: var(--primary-dark);
}

.composer-btn-submit:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
  .post-composer {
    background: #2a2a3a;
  }

  .composer-media-btn {
    background: #3a3a4a;
  }

  .composer-media-btn:hover {
    background: #4a4a5a;
  }

  .composer-btn-cancel {
    background: #3a3a4a;
    color: #fff;
  }

  .composer-btn-cancel:hover {
    background: #4a4a5a;
  }
}
