:root {
  --primary-color: #6366f1;
  --secondary-color: #8b5cf6;
  --accent-color: #06b6d4;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --background-light: #ffffff;
  --background-dark: linear-gradient(135deg, #1e1b4b 0%, #2a1a3d 100%);
  --surface-light: rgba(255, 255, 255, 0.95);
  --surface-dark: rgba(15, 15, 25, 0.95);
  --text-light: #1f2937;
  --text-dark: #f9fafb;
  --shadow-light: 0 10px 25px rgba(0, 0, 0, 0.1);
  --shadow-dark: 0 10px 25px rgba(0, 0, 0, 0.3);
  --border-radius: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--background-light);
  color: var(--text-light);
  transition: var(--transition);
  overflow-x: hidden;
}

body.dark {
  background: var(--background-dark);
  color: var(--text-dark);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  position: relative;
  z-index: 1;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 0;
  margin-bottom: 20px;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  transition: var(--transition);
}

.logo-link:hover {
  transform: scale(1.05);
}

.logo {
  height: 28px;
  width: 28px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.logo-text {
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-family: 'Poppins', sans-serif;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 10px;
  border-radius: 50%;
  transition: var(--transition);
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
}

body.dark .icon-btn {
  color: var(--text-dark);
}

.icon-btn:hover {
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.1);
}

.slideshow-container {
  max-width: 500px;
  margin: 0 auto 40px;
  overflow: hidden;
  position: relative;
}

.slideshow {
  position: relative;
  width: 100%;
  padding-top: 66.67%; /* 3:2 aspect ratio */
}

.slide {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity 1.5s ease-in-out;
}

.slide.active {
  display: block;
  opacity: 1;
}

.search-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin: 0 0 50px 0; /* Reduced margin to accommodate new layout */
}

.spacer {
  height: 60px; /* Equivalent to 3 lines of text, assuming ~20px per line */
}

.search-input-wrapper {
  position: relative;
  width: 100%;
  max-width: 700px;
}

.search-input {
  width: 100%;
  padding: 18px 50px 18px 24px;
  font-size: 1.1rem;
  font-family: Arial, sans-serif;
  border: 2px solid transparent;
  border-radius: var(--border-radius);
  outline: none;
  transition: var(--transition);
  height: 65px;
  background: var(--surface-light);
  box-shadow: var(--shadow-light);
  color: var(--text-light);
}

body.dark .search-input {
  background: var(--surface-dark);
  color: var(--text-dark);
}

.search-input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1);
  transform: translateY(-2px);
}

.search-input::placeholder {
  color: rgba(0, 0, 0, 0.5);
}

body.dark .search-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.search-icon {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  color: var(--accent-color);
  transition: var(--transition);
}

.search-input:focus + .search-icon {
  color: var(--primary-color);
}

.glossy-btn {
  padding: 16px 32px;
  font-size: 1.1rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-light);
  font-family: 'Inter', sans-serif;
  min-width: 150px;
  align-self: center;
}

body.dark .glossy-btn {
  box-shadow: var(--shadow-dark);
}

.glossy-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 35px rgba(99, 102, 241, 0.4);
}

.title {
  font-size: 2.2rem;
  text-align: center;
  margin: 0 0 50px 0;
  font-weight: 700;
  font-family: 'Poppins', sans-serif;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.typewriter {
  display: inline-block;
  border-right: 3px solid var(--accent-color);
  animation: blink 1s infinite;
  padding-right: 2px;
}

@keyframes blink {
  0%, 50% { border-color: transparent; }
  51%, 100% { border-color: var(--accent-color); }
}

.hidden {
  display: none;
}

.after-search-text {
  font-size: 1.3rem;
  text-align: center;
  margin: 40px 0;
  font-weight: 500;
  color: var(--text-light);
}

body.dark .after-search-text {
  color: var(--text-dark);
}

.user-query {
  font-weight: 700;
  color: var(--accent-color);
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin: 40px 0;
  justify-items: center;
}

.glossy-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
  border-radius: 20px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2), inset 0 2px 4px rgba(255, 255, 255, 0.3), inset 0 -2px 4px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: var(--transition);
  opacity: 0;
  transform: translateY(30px);
  text-decoration: none;
  width: 120px;
  height: 120px;
}

body.dark .glossy-icon {
  background: linear-gradient(135deg, rgba(15, 15, 25, 0.3), rgba(15, 15, 25, 0.2));
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.2), inset 0 -2px 4px rgba(0, 0, 0, 0.2);
}

.glossy-icon:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3), inset 0 4px 6px rgba(255, 255, 255, 0.4), inset 0 -4px 6px rgba(0, 0, 0, 0.15);
}

body.dark .glossy-icon:hover {
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5), inset 0 4px 6px rgba(255, 255, 255, 0.3), inset 0 -4px 6px rgba(0, 0, 0, 0.25);
}

.glossy-icon.opacity-100.translate-y-0 {
  opacity: 1;
  transform: translateY(0);
}

.icon-img {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0) 70%);
}

.icon-text {
  font-size: 0.95rem;
  text-align: center;
  font-weight: 500;
  color: var(--text-light);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

body.dark .icon-text {
  color: var(--text-dark);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.modal-btn-wrapper {
  text-align: center;
  margin: 30px 0;
}

.info-btn {
  background: linear-gradient(135deg, var(--success-color), #059669);
}

.info-btn:hover {
  box-shadow: 0 15px 35px rgba(16, 185, 129, 0.4);
}

.history {
  margin: 50px 0;
  padding: 30px;
  background: var(--surface-light);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-light);
}

body.dark .history {
  background: var(--surface-dark);
  box-shadow: var(--shadow-dark);
}

.history-title {
  font-size: 1.6rem;
  margin-bottom: 20px;
  text-align: center;
  color: var(--primary-color);
}

.history-list {
  list-style: none;
  padding: 0;
  max-height: 300px;
  overflow-y: auto;
}

.history-item {
  padding: 15px;
  background: rgba(255, 255, 255, 0.5);
  margin-bottom: 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition);
  border-left: 4px solid var(--accent-color);
}

body.dark .history-item {
  background: rgba(255, 255, 255, 0.1);
}

.history-item:hover {
  background: rgba(99, 102, 241, 0.1);
  transform: translateX(5px);
}

body.dark .history-item:hover {
  background: rgba(99, 102, 241, 0.2);
}

.footer {
  text-align: center;
  padding: 40px 0;
  font-size: 0.95rem;
  color: var(--text-light);
  opacity: 0.8;
}

body.dark .footer {
  color: var(--text-dark);
}

.footer-link {
  color: var(--accent-color);
  text-decoration: none;
  margin: 0 12px;
  transition: var(--transition);
  font-weight: 500;
}

.footer-link:hover {
  color: var(--primary-color);
  text-decoration: underline;
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  justify-content: center;
  align-items: center;
  z-index: 2000;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--surface-light);
  padding: 32px;
  border-radius: var(--border-radius);
  max-width: 600px;
  width: 90%;
  box-shadow: var(--shadow-light);
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  animation: slideIn 0.3s ease;
}

body.dark .modal-content {
  background: var(--surface-dark);
  box-shadow: var(--shadow-dark);
}

@keyframes slideIn {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-content .close {
  float: right;
  font-size: 2rem;
  cursor: pointer;
  color: var(--text-light);
  transition: var(--transition);
}

body.dark .modal-content .close {
  color: var(--text-dark);
}

.modal-content .close:hover {
  color: var(--danger-color);
  transform: scale(1.1);
}

.modal-title {
  font-size: 1.8rem;
  margin-bottom: 20px;
  color: var(--primary-color);
  text-align: center;
}

.modal-img {
  width: 100%;
  height: auto;
  margin: 20px 0;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-light);
}

body.dark .modal-img {
  box-shadow: var(--shadow-dark);
}

.modal-list {
  padding-left: 24px;
  margin: 20px 0;
  line-height: 1.6;
}

.modal-list li {
  margin-bottom: 10px;
  color: var(--text-light);
}

body.dark .modal-list li {
  color: var(--text-dark);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  .toolbar {
    padding: 10px 0;
  }

  .logo-text {
    font-size: 1rem;
  }

  .title {
    font-size: 1.6rem;
    margin-bottom: 30px;
  }

  .search-input {
    font-size: 1rem;
    height: 55px;
    padding: 14px 40px 14px 20px;
  }

  .glossy-btn {
    padding: 14px 28px;
    font-size: 1rem;
    min-width: 120px;
  }

  .search-row {
    margin-bottom: 30px; /* Adjusted for mobile */
  }

  .spacer {
    height: 60px; /* Maintains 3-line spacing on mobile */
  }

  .icon-grid {
    grid-template-columns: repeat(2, 1fr); /* 2 columns on tablets */
    gap: 16px;
  }

  .glossy-icon {
    padding: 16px;
    width: 100px;
    height: 100px;
  }

  .icon-img {
    width: 40px;
    height: 40px;
  }

  .history {
    padding: 20px;
    margin: 30px 0;
  }

  .modal-content {
    padding: 24px;
    width: 95%;
  }

  .slideshow-container {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .title {
    font-size: 1.4rem;
  }

  .after-search-text {
    font-size: 1.1rem;
  }

  .icon-grid {
    grid-template-columns: repeat(2, 1fr); /* 2 columns on phones */
  }

  .spacer {
    height: 60px; /* Ensures stability with 3-line spacing */
  }
}

@media (min-width: 769px) {
  .icon-grid {
    grid-template-columns: repeat(3, 1fr); /* Maintain 3x3 on big screens */
  }
}