* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #171a2b;
  background: #f6f8ff;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(224, 231, 255, 0.72) 0, rgba(246, 248, 255, 0) 48%),
    #f6f8ff;
}

.topbar {
  height: 76px;
  padding: 0 clamp(22px, 5vw, 72px);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 24px;
}

.theme-toggle {
  padding: 8px 12px;
  border: 1px solid #e1e4ef;
  border-radius: 999px;
  color: #666d81;
  background: rgba(255, 255, 255, 0.72);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.theme-toggle:hover {
  color: #5a60e8;
  border-color: #b9bded;
}

.theme-toggle:focus-visible {
  outline: 3px solid rgba(89, 87, 223, 0.35);
  outline-offset: 3px;
}

.about-link {
  color: #666d81;
  font-size: 14px;
  text-decoration: none;
  transition: color 160ms ease;
}

.about-link:hover {
  color: #5a60e8;
}

.search-home {
  width: min(100% - 40px, 680px);
  margin: auto;
  padding: 28px 0 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transform: translateY(-22px);
}

.flux-logo {
  display: block;
  width: min(220px, 58vw);
  height: auto;
  max-height: 160px;
  object-fit: contain;
}

.tagline {
  margin: 12px 0 34px;
  color: #777d91;
  font-size: 16px;
  letter-spacing: 0.02em;
}

.search-form {
  width: 100%;
  height: 60px;
  padding: 0 9px 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #e4e7f1;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 35px rgba(54, 66, 135, 0.08), 0 2px 6px rgba(54, 66, 135, 0.04);
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.search-form:focus-within {
  border-color: #aab0ff;
  box-shadow: 0 12px 38px rgba(81, 91, 213, 0.14), 0 0 0 4px rgba(107, 116, 245, 0.08);
  transform: translateY(-1px);
}

.search-icon,
.search-button {
  flex: 0 0 auto;
}

.search-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: #9399aa;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.search-site {
  flex: 0 1 150px;
  min-width: 0;
  max-width: 150px;
  height: 34px;
  padding: 0 10px 0 0;
  border: 0;
  border-right: 1px solid #e4e7f1;
  outline: 0;
  color: #666d81;
  background: transparent;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.search-form input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  color: #25283a;
  background: transparent;
  font: inherit;
  font-size: 16px;
}

.search-form input::placeholder {
  color: #a0a5b4;
}

.search-form input::-webkit-search-cancel-button {
  cursor: pointer;
}

.search-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(135deg, #7978f7, #5957df);
  cursor: pointer;
  transition: box-shadow 160ms ease, transform 160ms ease;
}

.search-button:hover {
  box-shadow: 0 5px 13px rgba(89, 87, 223, 0.3);
  transform: translateY(-1px);
}

.search-button:focus-visible,
.about-link:focus-visible {
  outline: 3px solid rgba(89, 87, 223, 0.35);
  outline-offset: 3px;
}

.search-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hint {
  margin: 19px 0 0;
  color: #969bad;
  font-size: 13px;
}

footer {
  min-height: 64px;
  padding: 18px clamp(22px, 5vw, 72px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border-top: 1px solid rgba(220, 224, 239, 0.72);
  color: #858b9e;
  font-size: 12px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body[data-theme="dark"] {
  color-scheme: dark;
  color: #eef0ff;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(47, 53, 99, 0.45) 0, rgba(20, 22, 38, 0) 48%),
    #141626;
}

body[data-theme="dark"] .theme-toggle {
  color: #c7c9df;
  border-color: #3a3d55;
  background: rgba(35, 38, 59, 0.8);
}

body[data-theme="dark"] .theme-toggle:hover,
body[data-theme="dark"] .about-link:hover {
  color: #aaaaff;
}

body[data-theme="dark"] .about-link {
  color: #b0b3c8;
}

body[data-theme="dark"] .tagline {
  color: #b2b5ca;
}

body[data-theme="dark"] .search-form {
  border-color: #383b53;
  background: rgba(31, 34, 53, 0.94);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.22), 0 2px 6px rgba(0, 0, 0, 0.14);
}

body[data-theme="dark"] .search-form:focus-within {
  border-color: #7778dd;
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.3), 0 0 0 4px rgba(107, 116, 245, 0.14);
}

body[data-theme="dark"] .search-site {
  border-right-color: #383b53;
  color: #b2b5ca;
}

body[data-theme="dark"] .search-form input {
  color: #f0f1ff;
}

body[data-theme="dark"] .search-form input::placeholder,
body[data-theme="dark"] .search-icon svg {
  color: #a0a4bb;
  stroke: #a0a4bb;
}

body[data-theme="dark"] .hint {
  color: #a0a4bb;
}

body[data-theme="dark"] footer {
  border-top-color: rgba(66, 69, 94, 0.72);
  color: #a0a4bb;
}

.search-results-page {
  width: min(100% - 40px, 760px);
  margin: 0 auto;
  padding: 12px 0 48px;
  flex: 1;
}

.results-heading {
  margin: 18px 0 0;
  color: #eef0ff;
  font-size: 22px;
  font-weight: 600;
}

.results-page-form {
  margin-top: 24px;
}

.search-results-page .results {
  margin-top: 18px;
}

.site-category {
  min-width: 0;
}

.site-category-title {
  margin: 8px 0 12px;
  color: #eef0ff;
  font-size: 18px;
  font-weight: 600;
}

.site-category-sites {
  display: grid;
  gap: 12px;
}

.site-search {
  width: 100%;
  height: 48px;
  margin-top: 20px;
  padding: 0 15px;
  border: 1px solid #383b53;
  border-radius: 12px;
  color: #f0f1ff;
  background: rgba(31, 34, 53, 0.94);
  font: inherit;
  font-size: 14px;
}

.site-search:focus-visible {
  outline: 3px solid rgba(107, 116, 245, 0.35);
  outline-offset: 2px;
}

.site-search-status {
  width: 100%;
  min-height: 20px;
  margin: 10px 0 0;
  color: #a0a4bb;
  font-size: 13px;
  text-align: left;
}

.results {
  width: 100%;
  margin-top: 22px;
  display: grid;
  gap: 12px;
  text-align: left;
}

.results[hidden] {
  display: none;
}

.result-card {
  padding: 17px 19px;
  border: 1px solid #383b53;
  border-radius: 14px;
  background: rgba(31, 34, 53, 0.82);
}

.result-title {
  color: #aaaaff;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
}

.result-title:hover {
  text-decoration: underline;
}

.result-description {
  margin: 7px 0 5px;
  color: #d0d2e2;
  font-size: 14px;
  line-height: 1.5;
}

.result-url {
  margin: 0;
  color: #969bb3;
  font-size: 12px;
}

.settings-page {
  width: min(100% - 40px, 680px);
  margin: 0 auto;
  padding: 12px 0 48px;
  flex: 1;
}

.settings-page > .flux-logo {
  margin: 0 auto;
}

.settings-page > .results-heading,
.settings-intro {
  text-align: center;
}

.settings-intro {
  margin: 10px 0 28px;
}

.settings-card {
  margin-top: 14px;
  padding: 22px;
  border: 1px solid #383b53;
  border-radius: 16px;
  background: rgba(31, 34, 53, 0.82);
}

.settings-card h2 {
  margin: 0 0 16px;
  color: #eef0ff;
  font-size: 17px;
}

.settings-card > label,
.gradient-fields label,
.custom-background-options > label {
  display: block;
  margin: 13px 0 8px;
  color: #d0d2e2;
  font-size: 14px;
}

.settings-control {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #454962;
  border-radius: 10px;
  color: #f0f1ff;
  background: #202239;
  font: inherit;
  font-size: 14px;
}

.settings-control:focus-visible,
.color-control:focus-visible,
.secondary-button:focus-visible {
  outline: 3px solid rgba(107, 116, 245, 0.4);
  outline-offset: 2px;
}

.settings-help {
  margin: 9px 0 0;
  color: #a0a4bb;
  font-size: 12px;
  line-height: 1.55;
}

.custom-background-options {
  margin-top: 20px;
}

.custom-background-options[hidden] {
  display: none;
}

.gradient-fields {
  margin: 0 0 18px;
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr 52px;
  align-items: center;
  gap: 12px;
  border: 1px solid #454962;
  border-radius: 12px;
}

.gradient-fields legend {
  padding: 0 6px;
  color: #d0d2e2;
  font-size: 13px;
}

.gradient-fields label {
  margin: 0;
}

.color-control {
  width: 48px;
  height: 36px;
  padding: 3px;
  border: 1px solid #454962;
  border-radius: 8px;
  background: #202239;
  cursor: pointer;
}

.setting-check {
  display: flex;
  align-items: center;
  gap: 11px;
  color: #d0d2e2;
  font-size: 14px;
  cursor: pointer;
}

.setting-check input {
  width: 17px;
  height: 17px;
  accent-color: #7778f7;
}

.settings-actions {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.secondary-button {
  padding: 10px 15px;
  border: 1px solid #454962;
  border-radius: 10px;
  color: #d0d2e2;
  background: rgba(31, 34, 53, 0.82);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.secondary-button:hover {
  border-color: #7778dd;
}

.settings-status {
  margin: 0;
  color: #a0a4bb;
  font-size: 13px;
}

body[data-theme="light"] .results-heading,
body[data-theme="light"] .site-category-title {
  color: #171a2b;
}

body[data-theme="light"] .result-card,
body[data-theme="light"] .settings-card {
  border-color: #e1e4ef;
  background: rgba(255, 255, 255, 0.82);
}

body[data-theme="light"] .result-description,
body[data-theme="light"] .settings-card > label,
body[data-theme="light"] .gradient-fields label,
body[data-theme="light"] .custom-background-options > label,
body[data-theme="light"] .setting-check {
  color: #3f4355;
}

body[data-theme="light"] .settings-card h2 {
  color: #171a2b;
}

body[data-theme="light"] .result-title {
  color: #514fd0;
}

body[data-theme="light"] .result-url,
body[data-theme="light"] .settings-help,
body[data-theme="light"] .settings-status {
  color: #73798c;
}

body[data-theme="light"] .settings-control {
  border-color: #d8dceb;
  color: #25283a;
  background: #fff;
}

body[data-theme="light"] .gradient-fields {
  border-color: #d8dceb;
}

body[data-theme="light"] .gradient-fields legend {
  color: #3f4355;
}

body[data-theme="light"] .secondary-button {
  border-color: #d8dceb;
  color: #3f4355;
  background: #fff;
}

body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  scroll-behavior: auto !important;
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

@media (max-width: 520px) {
  .topbar {
    height: 62px;
  }

  .search-home {
    transform: translateY(-10px);
  }

  .search-form {
    height: 56px;
    border-radius: 16px;
    padding-left: 16px;
  }

  .search-site {
    flex-basis: 112px;
    max-width: 112px;
    font-size: 12px;
  }

  .search-button {
    width: 40px;
    height: 40px;
  }
}
