:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f8f9fa;
  --text: #202124;
  --muted: #5f6368;
  --line: #dfe1e5;
  --line-soft: #ebedf0;
  --blue: #1a73e8;
  --blue-hover: #1558b0;
  --green: #188038;
  --shadow: 0 1px 6px rgba(32, 33, 36, .28);
  --shadow-soft: 0 2px 12px rgba(60, 64, 67, .13);
  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius-md: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101214;
  --surface: #17191c;
  --surface-soft: #202327;
  --text: #e8eaed;
  --muted: #a9adb3;
  --line: #3c4043;
  --line-soft: #292d31;
  --blue: #8ab4f8;
  --blue-hover: #aecbfa;
  --green: #81c995;
  --shadow: 0 1px 6px rgba(0, 0, 0, .7);
  --shadow-soft: 0 2px 14px rgba(0, 0, 0, .36);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.topbar {
  width: 100%;
  min-height: 64px;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mini-brand {
  color: var(--text);
  text-decoration: none;
  font-size: 20px;
  letter-spacing: -.4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
body.has-results .mini-brand { opacity: 1; pointer-events: auto; }
.mini-brand strong { color: var(--blue); font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}
.icon-button:hover { background: var(--surface-soft); color: var(--text); }
.icon-button svg { width: 20px; height: 20px; }
.admin-link {
  min-height: 38px;
  padding: 0 16px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: #fff;
  background: #1a73e8;
  font-size: 14px;
  font-weight: 600;
}
.admin-link:hover { background: #1558b0; }

main { flex: 1; width: 100%; }
.hero {
  width: min(100% - 32px, 720px);
  margin: clamp(90px, 18vh, 180px) auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: margin .25s ease, width .25s ease;
}
body.has-results .hero {
  width: min(100% - 48px, 860px);
  margin-top: 14px;
  align-items: stretch;
}
body.has-results .brand-mark,
body.has-results .tagline,
body.has-results .quick-access,
body.has-results .helper-text { display: none; }

.brand-mark {
  margin: 0 0 18px;
  font-size: clamp(48px, 8vw, 76px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -4px;
  user-select: none;
}
.brand-blue { color: #4285f4; }
.brand-red { color: #ea4335; }
.brand-yellow { color: #fbbc05; }
.brand-green { color: #34a853; }
.tagline {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 16px;
  text-align: center;
}
.search-form { width: 100%; position: relative; z-index: 10; }
.search-box {
  width: 100%;
  height: 52px;
  padding: 0 7px 0 16px;
  border: 1px solid var(--line);
  border-radius: 28px;
  display: grid;
  grid-template-columns: 24px 1fr auto 42px;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  transition: border-color .18s ease, box-shadow .18s ease;
}
.search-box:hover,
.search-box:focus-within,
.search-box.is-open {
  border-color: transparent;
  box-shadow: var(--shadow);
}
.search-icon { width: 20px; height: 20px; color: var(--muted); }
.search-box input {
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 16px;
}
.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: 36px;
  color: var(--muted);
  border-right: 1px solid var(--line);
  border-radius: 0;
  padding-right: 10px;
}
.clear-button svg { width: 19px; height: 19px; }
.submit-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: var(--blue);
}
.submit-button:hover { background: var(--surface-soft); }
.submit-button svg { width: 21px; height: 21px; }

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

.quick-access {
  width: 100%;
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.quick-label { color: var(--muted); font-size: 13px; }
.quick-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; }
.quick-chip {
  min-height: 36px;
  padding: 0 15px;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  color: var(--text);
  background: var(--surface-soft);
  cursor: pointer;
  font-size: 14px;
}
.quick-chip:hover { border-color: var(--line); box-shadow: var(--shadow-soft); }
.helper-text { margin: 22px 0 0; color: var(--muted); font-size: 13px; text-align: center; }

.results-section {
  width: min(100% - 48px, 860px);
  margin: 28px auto 56px;
}
.results-meta { margin-bottom: 20px; color: var(--muted); font-size: 13px; }
.correction {
  margin: -8px 0 22px;
  color: var(--muted);
  font-size: 14px;
}
.correction button {
  padding: 0;
  border: 0;
  color: var(--blue);
  background: transparent;
  cursor: pointer;
}
.results-list { display: flex; flex-direction: column; gap: 30px; }
.result-card { max-width: 690px; }
.result-source {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
}
.result-favicon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--blue);
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}
.result-source-text { min-width: 0; }
.result-name { display: block; font-size: 14px; color: var(--text); }
.result-url { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-title {
  display: inline-block;
  margin: 0 0 6px;
  color: var(--blue);
  text-decoration: none;
  font-size: 20px;
  line-height: 1.3;
  font-weight: 500;
}
.result-title:hover { text-decoration: underline; }
.result-description { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.58; }
.result-tags { display: flex; gap: 8px; margin-top: 10px; }
.result-tag { padding: 4px 9px; border-radius: 12px; color: var(--muted); background: var(--surface-soft); font-size: 12px; }
.empty-state {
  padding: 32px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
}
.empty-state h2 { margin: 0 0 8px; font-size: 20px; }
.empty-state p { margin: 0; color: var(--muted); line-height: 1.55; }

.pagination { display: flex; gap: 7px; margin-top: 38px; flex-wrap: wrap; }
.page-button {
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 19px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}
.page-button:hover { border-color: var(--blue); color: var(--blue); }
.page-button.is-current { border-color: var(--blue); color: #fff; background: #1a73e8; }
.page-button:disabled { opacity: .4; cursor: not-allowed; }

.skeleton-card { max-width: 690px; }
.skeleton-line { height: 13px; margin: 8px 0; border-radius: 7px; background: linear-gradient(90deg, var(--surface-soft), var(--line-soft), var(--surface-soft)); background-size: 220% 100%; animation: shimmer 1.3s linear infinite; }
.skeleton-line.short { width: 34%; }
.skeleton-line.medium { width: 70%; height: 20px; }
.skeleton-line.long { width: 92%; }
@keyframes shimmer { to { background-position: -220% 0; } }

.footer {
  min-height: 72px;
  padding: 18px 28px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 13px;
}
.footer p { margin: 0; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 100;
  max-width: min(90vw, 420px);
  padding: 12px 18px;
  border-radius: 10px;
  color: #fff;
  background: #303134;
  box-shadow: var(--shadow-soft);
  transform: translateX(-50%);
  font-size: 14px;
}

@media (max-width: 700px) {
  .topbar { min-height: 58px; padding: 10px 14px; }
  .hero { width: min(100% - 26px, 720px); margin-top: clamp(70px, 14vh, 120px); }
  body.has-results .hero, .results-section { width: min(100% - 26px, 860px); }
  .brand-mark { font-size: 48px; letter-spacing: -3px; }
  .tagline { max-width: 320px; font-size: 14px; }
  .search-box { height: 50px; padding-left: 14px; gap: 8px; }
  .search-icon { display: none; }
  .search-box { grid-template-columns: 1fr auto 40px; }
  .search-box input { font-size: 15px; }
  .results-section { margin-top: 22px; }
  .result-title { font-size: 19px; }
  .footer { align-items: flex-start; flex-direction: column; }
}

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