:root {
  --bg-color: #ffffff;
  --text-color: #202124;
  --link-color: #1a0dab;
  --link-hover: #1a0dab;
  --border-color: #dfe1e5;
  --input-bg: #ffffff;
  --btn-bg: #f8f9fa;
  --btn-border: #f8f9fa;
  --btn-text: #3c4043;
  --btn-hover-border: #dadce0;
  --btn-hover-box-shadow: 0 1px 1px rgba(0,0,0,.1);
  --result-url: #202124;
  --result-snippet: #4d5156;
  --header-bg: #ffffff;
  --logo-blue: #4285f4;
  --logo-red: #ea4335;
  --logo-yellow: #fbbc05;
  --logo-green: #34a853;
}

body.dark-mode {
  --bg-color: #202124;
  --text-color: #e8eaed;
  --link-color: #8ab4f8;
  --link-hover: #8ab4f8;
  --border-color: #5f6368;
  --input-bg: #202124;
  --btn-bg: #303134;
  --btn-border: #303134;
  --btn-text: #e8eaed;
  --btn-hover-border: #5f6368;
  --btn-hover-box-shadow: 0 1px 1px rgba(255,255,255,.1);
  --result-url: #bdc1c6;
  --result-snippet: #bdc1c6;
  --header-bg: #202124;
}

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

body {
  font-family: arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s, color 0.3s;
}

a {
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Header & Dark Mode Toggle */
header {
  display: flex;
  justify-content: flex-end;
  padding: 15px;
  background-color: var(--header-bg);
}

.dark-mode-toggle {
  background: none;
  border: none;
  color: var(--text-color);
  font-size: 24px;
  cursor: pointer;
}

/* Homepage */
.home-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 10vh;
}

.logo {
  font-size: 80px;
  font-weight: bold;
  letter-spacing: -3px;
  margin-bottom: 20px;
}
.logo span:nth-child(1) { color: var(--logo-blue); }
.logo span:nth-child(2) { color: var(--logo-red); }
.logo span:nth-child(3) { color: var(--logo-yellow); }
.logo span:nth-child(4) { color: var(--logo-blue); }
.logo span:nth-child(5) { color: var(--logo-green); }
.logo span:nth-child(6) { color: var(--logo-red); }
.logo span:nth-child(7) { color: var(--logo-yellow); }
.logo span:nth-child(8) { color: var(--logo-blue); }

.search-container {
  width: 100%;
  max-width: 584px;
  position: relative;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 0 14px 0 14px;
  height: 46px;
  box-shadow: none;
  transition: box-shadow 0.2s;
  position: relative;
  z-index: 3;
}

.search-box:hover, .search-box.active {
  box-shadow: 0 1px 6px rgba(32,33,36,.28);
  border-color: transparent;
}
body.dark-mode .search-box:hover, body.dark-mode .search-box.active {
  box-shadow: 0 1px 6px rgba(255,255,255,.2);
}

.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-color);
  font-size: 16px;
  outline: none;
  padding: 0 10px;
  height: 100%;
}

.search-icon {
  color: #9aa0a6;
  font-size: 18px;
}

.voice-btn, .clear-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 8px;
  font-size: 18px;
}

.voice-btn {
  color: #4285f4;
}

.clear-btn {
  color: #70757a;
  display: none;
}
.clear-btn.visible {
  display: block;
}

.buttons {
  margin-top: 24px;
  display: flex;
  gap: 12px;
  justify-content: center;
}

.buttons button {
  background-color: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 4px;
  color: var(--btn-text);
  font-family: arial,sans-serif;
  font-size: 14px;
  margin: 11px 4px;
  padding: 0 16px;
  line-height: 27px;
  height: 36px;
  min-width: 54px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.buttons button:hover {
  box-shadow: var(--btn-hover-box-shadow);
  border: 1px solid var(--btn-hover-border);
  color: var(--text-color);
}

/* Suggestions Dropdown */
.suggestions-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 0 0 24px 24px;
  box-shadow: 0 4px 6px rgba(32,33,36,.28);
  display: none;
  z-index: 2;
  margin-top: -20px;
  padding-top: 20px;
  padding-bottom: 10px;
}
body.dark-mode .suggestions-dropdown {
  box-shadow: 0 4px 6px rgba(255,255,255,.2);
}

.suggestions-dropdown.active {
  display: block;
}

.suggestion-item {
  padding: 8px 20px;
  display: flex;
  align-items: center;
  cursor: pointer;
  color: var(--text-color);
}

.suggestion-item:hover {
  background-color: var(--btn-bg);
}
.suggestion-icon {
  margin-right: 15px;
  color: #9aa0a6;
}

/* Results Page Header */
.results-header {
  display: flex;
  align-items: center;
  padding: 20px 20px 0 20px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.results-logo {
  font-size: 32px;
  font-weight: bold;
  letter-spacing: -1px;
  margin-right: 40px;
  margin-bottom: 20px;
}
.results-logo span:nth-child(1) { color: var(--logo-blue); }
.results-logo span:nth-child(2) { color: var(--logo-red); }
.results-logo span:nth-child(3) { color: var(--logo-yellow); }
.results-logo span:nth-child(4) { color: var(--logo-blue); }
.results-logo span:nth-child(5) { color: var(--logo-green); }
.results-logo span:nth-child(6) { color: var(--logo-red); }
.results-logo span:nth-child(7) { color: var(--logo-yellow); }
.results-logo span:nth-child(8) { color: var(--logo-blue); }


.results-search-container {
  width: 100%;
  max-width: 692px;
  margin-bottom: 20px;
  flex: 1;
}

.results-header-right {
  margin-left: auto;
  margin-bottom: 20px;
}

/* Results Navigation */
.results-nav {
  display: flex;
  margin-left: 170px;
  gap: 20px;
  margin-top: 10px;
}

.nav-item {
  padding: 10px 10px 12px;
  color: var(--text-color);
  font-size: 14px;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

.nav-item.active {
  color: var(--logo-blue);
  border-bottom: 3px solid var(--logo-blue);
}

/* Results Body */
.results-main {
  padding: 20px 20px 20px 170px;
  max-width: 800px;
}

#stats {
  color: #70757a;
  font-size: 14px;
  margin-bottom: 20px;
}
body.dark-mode #stats {
  color: #9aa0a6;
}

.result-card {
  margin-bottom: 30px;
  display: flex;
  gap: 15px;
}

.result-img-container {
  flex-shrink: 0;
  width: 100px;
  display: flex;
  flex-direction: column;
}

.result-img {
  width: 100px;
  height: auto;
  border-radius: 8px;
  object-fit: cover;
  background-color: var(--btn-bg);
}

.result-content {
  flex: 1;
}

.result-url {
  font-size: 14px;
  color: var(--result-url);
  margin-bottom: 5px;
  display: block;
}

.result-title {
  font-size: 20px;
  color: var(--link-color);
  margin-bottom: 2px;
  font-weight: 400;
  line-height: 1.3;
}
.result-title:hover {
  text-decoration: underline;
}

.result-content h3 {
  font-weight: normal;
  margin-bottom: 5px;
}

.result-snippet {
  font-size: 14px;
  color: var(--result-snippet);
  line-height: 1.58;
}

/* Highlighted match from Wikipedia API */
.searchmatch {
  font-weight: bold;
}

.loading, .error-message {
  padding: 20px 0;
  color: var(--text-color);
}

/* Footer */
footer {
  background-color: var(--btn-bg);
  color: #70757a;
  padding: 15px 30px;
  font-size: 14px;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}
body.dark-mode footer {
  color: #9aa0a6;
}

/* Responsive */
@media screen and (max-width: 768px) {
  .results-main {
    padding: 20px;
  }
  .results-nav {
    margin-left: 20px;
  }
  .search-container {
    padding: 0 20px;
  }
}

@media screen and (max-width: 480px) {
  .logo {
    font-size: 50px;
  }
  .buttons button {
    padding: 0 10px;
  }
  .result-card {
    flex-direction: column;
  }
  .result-img-container {
    width: 100%;
    max-width: 150px;
  }
  .result-img {
    width: 100%;
  }
  .results-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .results-header-right {
    position: absolute;
    top: 20px;
    right: 20px;
    margin: 0;
  }
}
