:root {
  --primary: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.5);
  --secondary: #06b6d4;
  --bg-dark: #0f172a;
  --card-bg: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.1);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
}

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

body {
  font-family: "Outfit", sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.7;
  /* Slightly increased for readability */
}

/* Background Animations */
.background-blobs {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  filter: blur(100px);
  opacity: 0.6;
}

.blob {
  position: absolute;
  width: 50vw;
  height: 50vw;
  border-radius: 50%;
  animation: move 20s infinite alternate;
}

.blob-1 {
  background: var(--primary);
  top: -10%;
  right: -10%;
}

.blob-2 {
  background: var(--secondary);
  bottom: -10%;
  left: -10%;
  animation-delay: -5s;
}

.blob-3 {
  background: #a855f7;
  top: 40%;
  left: 40%;
  width: 30vw;
  height: 30vw;
  animation-delay: -10s;
}

@keyframes move {
  from {
    transform: translate(0, 0) scale(1);
  }

  to {
    transform: translate(20px, 40px) scale(1.1);
  }
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(2rem, 8vw, 6rem) clamp(1rem, 5vw, 2rem);
}

/* Header */
.hero {
  text-align: center;
  margin-bottom: 4rem;
}

h1 {
  font-family: "Playfair Display", serif;
  font-size: clamp(2.5rem, 10vw, 4.5rem);
  /* Fluid typography */
  line-height: 1.1;
  margin-bottom: 1rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.accent {
  -webkit-text-fill-color: var(--text-main);
}

.subtitle {
  color: var(--text-muted);
  font-size: clamp(1rem, 4vw, 1.25rem);
  font-weight: 300;
  max-width: 600px;
  margin: 0 auto;
}

/* Search Box */
.search-section {
  margin-bottom: 1.5rem;
  /* Reduced to ~1cm gap combined with daily container */
}

.search-box {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 0.5rem;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 20px var(--primary-glow);
  transform: translateY(-2px);
}

#searchInput {
  width: 100%;
  background: transparent;
  border: none;
  padding: 1rem 1.5rem 1rem 4rem;
  color: var(--text-main);
  font-size: 1.15rem;
  outline: none;
}

#searchInput::placeholder {
  color: rgba(255, 255, 255, 0.5);
  opacity: 1;
  /* Firefox default is lower */
}

.success-message {
  color: #34d399 !important; /* Green-400 equivalent for visibility on dark */
  font-weight: bold !important;
  text-align: center;
}

.search-icon {
  position: absolute;
  left: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 24px;
  height: 24px;
}

/* Result Count */
.result-count {
  color: var(--text-muted);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  text-align: right;
  padding: 0 0.5rem;
}

/* Results Grid */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 350px), 1fr));
  gap: 2rem;
  min-height: 200px;
}

.expression-card {
  background: rgba(255, 255, 255, 0.05);
  /* Increased for better contrast */
  border: 1px solid var(--glass-border);
  border-radius: 28px;
  padding: clamp(1.5rem, 5vw, 2.5rem);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.expression-card:hover {
  transform: translateY(-10px);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.card-header .text {
  font-size: 1.5rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 0.5rem;
}

.card-header .meaning {
  color: var(--secondary);
  font-size: 1rem;
  font-weight: 400;
  display: block;
}

.synonyms-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.synonym-tag {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  /* Lighter color for better readability on dark BG */
  padding: 0.5rem 1rem;
  border-radius: 99px;
  font-size: 0.9rem;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

/* States */
.loading-state,
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem;
  color: var(--text-muted);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--glass-border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1.5rem;
}

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

/* Progress Bar */
.progress-container {
  max-width: 400px;
  margin: 1.5rem auto 0;
  padding: 0 1rem;
}

.progress-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
  position: relative;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent-gradient);
  border-radius: 99px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 15px var(--primary-glow);
}

.progress-text {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.hidden {
  display: none !important;
}

/* Expression of the Day */
.daily-expression-container {
  margin-top: 1rem;
  text-align: left;
  animation: fadeIn 0.8s ease-out;
}

.daily-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  color: var(--text-main);
  font-family: "Playfair Display", serif;
  font-size: 1.5rem;
}

.daily-header svg {
  color: var(--secondary);
  width: 28px;
  height: 28px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile Adjustments */
@media (max-width: 768px) {
  .container {
    padding: 1rem 0;
    /* Zero side padding to strictly maximize width */
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
  }

  /* Compact Hero */
  .hero {
    margin-bottom: 1.5rem;
    /* Reduced from 2rem */
  }

  h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
  }

  .subtitle {
    font-size: 0.95rem;
    line-height: 1.4;
    padding: 0 1rem;
  }

  /* Compact Search Box */
  .search-section {
    padding: 0 1rem;
    /* Compensate for zero container padding */
    margin-bottom: 3.5rem;
    /* Increased to approx 1.5cm */
  }

  /* Compact Results Grid */
  .results-grid {
    padding: 0 1rem;
    gap: 1rem;
  }

  /* Pull Expression of the Day tight to the top */
  .daily-expression-container {
    padding: 0 1rem;
    /* Matched to results-grid logic */
    margin-top: 0;
    /* Removed negative margin to increase space */
  }

  /* Reduce card padding on mobile to allow wider text content */
  .expression-card {
    padding: 1.25rem;
  }

  /* Compact Daily Header to remove visual gap */
  .daily-header {
    font-size: 1.35rem;
    /* Slightly larger as requested */
    margin-bottom: 0.75rem;
    /* Slightly increased gap */
    gap: 0.5rem;
    justify-content: center;
    /* Center align on mobile */
  }

  .daily-header svg {
    width: 20px;
    height: 20px;
  }

  /* Reset default empty-state padding that constrains width */
  .empty-state {
    padding: 2rem 0;
  }

  /* Target the specific initial message instead of all p tags in empty-state */
  #initialStateMessage,
  .stats-text {
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }

  /* Optimize loading/progress visibility on small screens */
  .loading-state {
    padding: 2rem 1rem;
    /* Reduced from 4rem */
  }

  .progress-container {
    margin-top: 1rem;
    padding: 0;
  }

  .example-text {
    text-align: left !important;
  }

  .highlight {
    display: inline !important;
  }

  .stats-count {
    font-size: 0.9rem;
    color: var(--text-muted);
    opacity: 0.8;
  }

  .stats-link {
    display: inline-block;
    color: var(--secondary);
    text-decoration: none;
    font-weight: 500;
    padding: 0.4rem 1.2rem;
    border-radius: 99px;
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.2);
    transition: all 0.3s ease;
    cursor: pointer;
    font-size: 0.85rem;
    margin-top: 0.5rem;
  }

  .stats-link:hover {
    background: rgba(6, 182, 212, 0.2);
    border-color: var(--secondary);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(6, 182, 212, 0.3);
    color: #fff;
  }
}

/* Footer Styling */
footer {
  margin-top: auto;
  /* Pushes footer to bottom in flex container */
  padding: 2rem 1rem;
  text-align: center;
  border-top: 1px solid var(--glass-border);
  background: rgba(15, 23, 42, 0.4);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

footer p {
  color: var(--text-muted);
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

footer a {
  color: var(--secondary);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s ease;
  position: relative;
  display: inline-block;
}

footer a::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 1px;
  bottom: -2px;
  left: 0;
  background-color: var(--secondary);
  transform: scaleX(0);
  transform-origin: bottom right;
  transition: transform 0.3s ease-out;
}

footer a:hover {
  color: var(--primary);
  text-shadow: 0 0 10px var(--primary-glow);
}

footer a:hover::after {
  transform: scaleX(1);
  transform-origin: bottom left;
  background-color: var(--primary);
}

/* Example Box Styles */
.example-box {
  margin-top: 1rem;
  padding: 1.25rem;
  background: rgba(0, 0, 0, 0.2);
  border-left: 4px solid var(--primary);
  border-radius: 12px;
}

.example-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--primary);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.example-text {
  font-size: 1rem;
  /* Better readability */
  color: #e2e8f0;
  line-height: 1.8;
  font-family: inherit;
  white-space: pre-line;
  /* Naturally handles newlines without needing br styling */
  text-align: left;
  /* Ensure dialogue is always left-aligned, overriding any parent centering */
}

/* Removed problematic br styling that caused unnecessary breaks */

.highlight {
  color: var(--primary);
  font-weight: 700;
  display: inline !important;
}

/* Error State */
.error-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: 20px;
  margin: 1rem 0;
}

.error-icon {
  color: #ef4444;
  width: 48px;
  height: 48px;
  margin: 0 auto 1rem;
}

.error-state h3 {
  color: #ef4444;
  margin-bottom: 0.5rem;
  font-size: 1.25rem;
}

.error-state p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.retry-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.75rem 2rem;
  border-radius: 99px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.retry-btn:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

/* Safari Fixes */
input[type="text"],
input[type="search"] {
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0;
  /* Reset for Safari */
}

/* Force border radius on our specific search input that was reset above */
#searchInput {
  border-radius: 20px;
}

/* Translation Block Styles */
.translation-container {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.translation-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.lang-label {
  font-family: "Outfit", sans-serif;
  font-weight: 600;
  font-size: 0.75rem;
  /* Smaller, tag-like */
  color: var(--text-secondary);
  /* Muted color */
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-width: 80px;
  /* Align text nicely */
  flex-shrink: 0;
}

.lang-text {
  color: var(--text-primary);
  font-weight: 400;
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .translation-row {
    flex-direction: column;
    gap: 0.2rem;
    align-items: flex-start;
  }

  .lang-label {
    min-width: auto;
    font-size: 0.7rem;
  }
}