:root {
  color-scheme: light;
  --background: #f6faff;
  --surface: #ffffff;
  --surface-low: #f0f4fa;
  --surface-container: #eaeef4;
  --surface-high: #e4e9ee;
  --surface-highest: #dee3e8;
  --text: #171c20;
  --text-variant: #424753;
  --outline: #727785;
  --outline-variant: #c2c6d5;
  --primary: #0058bd;
  --primary-hover: #004494;
  --primary-container: #d8e2ff;
  --secondary: #006e2c;
  --tertiary: #b51b15;
  --error: #ba1a1a;
  --error-container: #ffdad6;
  --ambient-shadow: 0 2px 8px rgba(23, 28, 32, .10);
  --focus-ring: 0 0 0 3px rgba(0, 88, 189, .16);
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;
  --page-gutter: clamp(16px, 3vw, 32px);
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-heading: "Plus Jakarta Sans", "Inter", ui-sans-serif, system-ui, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #111418;
  --surface: #171c20;
  --surface-low: #1d2227;
  --surface-container: #252a30;
  --surface-high: #2c3137;
  --surface-highest: #343a41;
  --text: #edf1f7;
  --text-variant: #c2c7d0;
  --outline: #9298a3;
  --outline-variant: #434952;
  --primary: #adc6ff;
  --primary-hover: #d8e2ff;
  --primary-container: #004494;
  --secondary: #89fa9b;
  --tertiary: #ffb4a9;
  --error: #ffb4ab;
  --error-container: #93000a;
  --ambient-shadow: 0 2px 10px rgba(0, 0, 0, .38);
  --focus-ring: 0 0 0 3px rgba(173, 198, 255, .18);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--background); scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background: var(--background);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
[hidden] { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Search input delegates focus styling to the pill wrapper, preventing
   the browser from drawing a hard rectangular box inside the search bar. */
.search-box input:focus,
.search-box input:focus-visible {
  outline: none;
  box-shadow: none;
}

.topbar {
  width: 100%;
  min-height: 64px;
  padding: 10px var(--page-gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar-leading,
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.menu-symbol,
.icon-button,
.profile-badge {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.menu-symbol { color: var(--text-variant); }
.menu-symbol svg,
.icon-button svg { width: 21px; height: 21px; }
.icon-button {
  border: 0;
  color: var(--text-variant);
  background: transparent;
  cursor: pointer;
  transition: color .18s ease, background-color .18s ease, transform .18s ease;
}
.icon-button:hover { color: var(--text); background: var(--surface-container); }
.icon-button:active { transform: scale(.95); }
.profile-badge {
  color: #ffffff;
  background: var(--primary);
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
}
.privacy-chip {
  min-height: 32px;
  padding: 0 13px;
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  color: var(--text-variant);
  background: var(--surface);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .02em;
}
.mini-brand {
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-heading);
  font-size: 19px;
  letter-spacing: -.5px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-6px);
  transition: opacity .2s ease, transform .2s ease;
}
body.has-results .mini-brand { opacity: 1; pointer-events: auto; transform: translateX(0); }
.mini-brand strong { color: var(--primary); font-weight: 700; }

main { flex: 1; width: 100%; }
.hero {
  width: min(calc(100% - 32px), 760px);
  margin: clamp(72px, 15vh, 156px) auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: margin .24s ease, width .24s ease, padding .24s ease;
}
.hero-copy { display: flex; flex-direction: column; align-items: center; }
.hero-kicker {
  margin: 0 0 14px;
  color: var(--text-variant);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .14em;
}
.brand-mark {
  margin: 0 0 18px;
  font-family: var(--font-heading);
  font-size: clamp(50px, 9vw, 76px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -4.5px;
  user-select: none;
}
.brand-blue { color: #4285f4; }
.brand-red { color: #ea4335; }
.brand-yellow { color: #fbbc05; }
.brand-green { color: #34a853; }
.tagline {
  max-width: 520px;
  margin: 0 0 28px;
  color: var(--text-variant);
  font-size: 16px;
  line-height: 24px;
  text-align: center;
}

.search-form { width: 100%; position: relative; z-index: 30; }
.search-box {
  width: 100%;
  min-height: 54px;
  padding: 0 7px 0 17px;
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-pill);
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto 42px;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  box-shadow: var(--ambient-shadow);
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease, border-radius .18s ease;
}
.search-box:hover {
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(23, 28, 32, .12);
}
.search-box:focus-within,
.search-box.is-open {
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(23, 28, 32, .16);
}
.search-icon { width: 20px; height: 20px; color: var(--outline); }
.search-box input {
  width: 100%;
  min-width: 0;
  height: 52px;
  border: 0;
  outline: 0;
  appearance: none;
  -webkit-appearance: none;
  color: var(--text);
  background: transparent;
  box-shadow: none;
  font-size: 16px;
  line-height: 24px;
}
.search-box input::placeholder { color: var(--outline); opacity: 1; }
.search-box input::-webkit-search-cancel-button { display: none; }
.clear-button,
.submit-button {
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.clear-button {
  width: 36px;
  height: 34px;
  padding-right: 10px;
  border-right: 1px solid var(--outline-variant);
  border-radius: 0;
  color: var(--text-variant);
}
.clear-button svg { width: 18px; height: 18px; }
.submit-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: var(--primary);
  transition: background-color .18s ease, transform .18s ease;
}
.submit-button:hover { background: var(--primary-container); }
.submit-button:active { transform: scale(.95); }
.submit-button svg { width: 21px; height: 21px; }

.suggestions {
  position: absolute;
  top: calc(100% - 1px);
  left: 0;
  right: 0;
  padding: 8px 0 10px;
  border: 1px solid var(--outline-variant);
  border-top: 0;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 8px 18px rgba(23, 28, 32, .14);
  overflow: hidden;
}
.search-box.is-open {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -1px 8px rgba(23, 28, 32, .08);
}
.suggestions ul { margin: 0; padding: 0; list-style: none; }
.suggestion-item {
  min-height: 52px;
  padding: 8px 18px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  cursor: pointer;
}
.suggestion-item:hover,
.suggestion-item.is-active { background: var(--surface-low); }
.suggestion-icon { width: 18px; height: 18px; color: var(--outline); }
.suggestion-main { min-width: 0; }
.suggestion-title {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.suggestion-meta {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--text-variant);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-access {
  width: 100%;
  margin-top: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.quick-label {
  color: var(--text-variant);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .04em;
}
.quick-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.quick-chip {
  min-height: 36px;
  padding: 0 15px;
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-pill);
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: border-color .18s ease, color .18s ease, background-color .18s ease;
}
.quick-chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-container); }
.helper-text {
  margin: 18px 0 0;
  color: var(--text-variant);
  font-size: 12px;
  line-height: 18px;
  text-align: center;
}

body.has-results .hero {
  width: 100%;
  margin: 0;
  padding: 12px var(--page-gutter) 18px;
  position: sticky;
  top: 0;
  z-index: 25;
  align-items: center;
  background: var(--background);
  background: color-mix(in srgb, var(--background) 94%, transparent);
  border-bottom: 1px solid var(--outline-variant);
  backdrop-filter: blur(10px);
}
body.has-results .hero-copy,
body.has-results .quick-access,
body.has-results .helper-text { display: none; }
body.has-results .search-form { width: min(100%, 760px); }

.results-section {
  width: min(calc(100% - 32px), 820px);
  margin: 22px auto 70px;
}
.results-meta {
  margin: 0 0 16px;
  color: var(--text-variant);
  font-size: 13px;
  line-height: 20px;
}
.correction {
  margin: 0 0 14px;
  padding: 12px 15px;
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-md);
  color: var(--text-variant);
  background: var(--surface);
  font-size: 14px;
}
.correction button {
  padding: 0;
  border: 0;
  color: var(--primary);
  background: transparent;
  cursor: pointer;
  font-weight: 600;
}
.results-list { display: flex; flex-direction: column; gap: 30px; }
.result-card {
  max-width: 720px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.skeleton-card,
.empty-state {
  padding: 20px;
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.result-source {
  width: fit-content;
  max-width: 100%;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}
.result-source:hover .result-name { text-decoration: underline; text-underline-offset: 2px; }
.result-favicon {
  position: relative;
  width: 28px;
  height: 28px;
  overflow: hidden;
  border: 1px solid var(--outline-variant);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: var(--surface);
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
}
.result-favicon img {
  position: absolute;
  inset: 3px;
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  object-fit: contain;
  border-radius: 50%;
  background: transparent;
}
.result-favicon.has-image .result-favicon-fallback { opacity: 0; }
.result-favicon-fallback { transition: opacity .12s ease; }
.result-source-text { min-width: 0; }
.result-name,
.result-url {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result-name { color: var(--text); font-size: 13px; font-weight: 600; line-height: 17px; }
.result-url { margin-top: 1px; color: var(--text-variant); font-size: 11px; line-height: 15px; }
.result-title {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin-top: 9px;
  overflow: hidden;
  color: var(--primary);
  font-family: var(--font-body);
  font-size: 20px;
  font-weight: 400;
  line-height: 27px;
  text-decoration: none;
  text-overflow: ellipsis;
}
.result-title:hover { text-decoration: underline; text-underline-offset: 3px; }
.result-title strong { font-weight: 600; }
.result-description {
  max-width: 70ch;
  margin: 4px 0 0;
  color: var(--text-variant);
  font-size: 13px;
  line-height: 20px;
}
.result-description strong { color: var(--text); font-weight: 600; }
.empty-state { padding-block: 42px; text-align: center; }
.empty-state h2 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 600;
}
.empty-state p { max-width: 520px; margin: 10px auto 0; color: var(--text-variant); font-size: 14px; line-height: 22px; }

.pagination { margin-top: 22px; display: flex; justify-content: center; gap: 7px; }
.page-button {
  min-width: 38px;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-pill);
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
.page-button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-button.is-current { border-color: var(--primary); color: #ffffff; background: var(--primary); }
.page-button:disabled { opacity: .42; cursor: not-allowed; }

.skeleton-card { overflow: hidden; }
.skeleton-line {
  height: 12px;
  margin-top: 12px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--surface-container) 25%, var(--surface-high) 45%, var(--surface-container) 65%);
  background-size: 200% 100%;
  animation: skeleton 1.25s linear infinite;
}
.skeleton-line:first-child { margin-top: 0; }
.skeleton-line.short { width: 30%; }
.skeleton-line.medium { width: 58%; }
.skeleton-line.long { width: 92%; }
@keyframes skeleton { to { background-position: -200% 0; } }

.footer {
  width: 100%;
  margin-top: auto;
  color: var(--text-variant);
  background: var(--surface-container);
  font-size: 12px;
}
.footer-location { padding: 13px var(--page-gutter); border-bottom: 1px solid var(--outline-variant); }
.footer-row {
  min-height: 54px;
  padding: 12px var(--page-gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.footer p { margin: 0; }
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  max-width: min(calc(100vw - 32px), 420px);
  padding: 13px 17px;
  border-radius: var(--radius-md);
  color: #ffffff;
  background: #2c3135;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .24);
  font-size: 13px;
  line-height: 19px;
}

@media (max-width: 680px) {
  .topbar { min-height: 58px; padding-inline: 12px; }
  .privacy-chip { display: none; }
  .hero { width: min(calc(100% - 28px), 760px); margin-top: clamp(48px, 12vh, 94px); }
  .hero-kicker { margin-bottom: 12px; }
  .brand-mark { font-size: clamp(46px, 16vw, 64px); letter-spacing: -3.5px; }
  .tagline { margin-bottom: 24px; font-size: 14px; line-height: 21px; }
  .search-box { min-height: 50px; grid-template-columns: 22px minmax(0, 1fr) auto 38px; padding-left: 15px; gap: 8px; }
  .search-box input { height: 48px; font-size: 15px; }
  .submit-button { width: 38px; height: 38px; }
  body.has-results .hero { padding: 10px 14px 14px; }
  .results-section { width: calc(100% - 28px); margin-top: 18px; }
  .skeleton-card, .empty-state { padding: 16px; border-radius: 14px; }
  .results-list { gap: 26px; }
  .result-title { font-size: 18px; line-height: 24px; }
  .footer-row { align-items: flex-start; flex-direction: column; gap: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
