:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --text: #1b1b1f;
  --muted: #62636b;
  --border: #e3e3de;
  --accent: #5b4cf0;
  --accent-soft: #ecebff;
  --ok: #18864b;
  --err: #c2342b;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 8px 24px rgb(0 0 0 / 0.06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111114;
    --surface: #1a1a1f;
    --surface-2: #232329;
    --text: #ececf1;
    --muted: #9a9ba5;
    --border: #2c2c34;
    --accent: #8c80ff;
    --accent-soft: #26244a;
    --ok: #4fc483;
    --err: #ff7b72;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- search bar ---------- */
.searchbar {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 6px 6px 18px; box-shadow: var(--shadow);
  transition: border-color .15s;
}
.searchbar:focus-within { border-color: var(--accent); }
.searchbar svg { flex: none; color: var(--muted); }
.searchbar input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  color: var(--text); font-size: 17px; padding: 10px 4px;
}
.searchbar button {
  border: 0; border-radius: 999px; background: var(--accent); color: #fff;
  padding: 10px 20px; font-weight: 600;
}

/* ---------- home ---------- */
.home {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 24px 16px 18vh;
}
.brand { font-size: clamp(40px, 8vw, 64px); font-weight: 800; letter-spacing: -0.04em; margin: 0; }
.brand span { color: var(--accent); }
.tagline { color: var(--muted); margin: 6px 0 28px; text-align: center; }
.home form { width: min(680px, 100%); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 6px 14px; font-size: 14px;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.search-count {
  margin: 22px 0 0; font-size: 14px; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 14px; background: var(--surface);
}
.search-count b { color: var(--accent); font-variant-numeric: tabular-nums; }
.engines-note { color: var(--muted); font-size: 13px; margin-top: 22px; text-align: center; }

/* ---------- results page ---------- */
header.top {
  position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.top-inner {
  max-width: 760px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 18px;
}
.top-inner .brand { font-size: 26px; }
.top-inner form { flex: 1; max-width: 680px; }
.top-inner .searchbar { box-shadow: none; padding-left: 14px; }
.top-inner .searchbar input { padding: 6px 4px; font-size: 16px; }
.top-inner .searchbar button { padding: 7px 16px; }

main.layout { max-width: 760px; margin: 0 auto; padding: 20px 16px 60px; }
@media (max-width: 640px) { .top-inner .brand { display: none; } }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* AI answer */
.answer { padding: 20px 22px; margin-bottom: 22px; }
.answer-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.answer-head .spark {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.answer-head h2 { font-size: 15px; margin: 0; }
.answer-head .model { margin-left: auto; color: var(--muted); font-size: 12px; }
.answer-body { font-size: 16px; }
.answer-body p { margin: 0 0 10px; }
.answer-body ul, .answer-body ol { margin: 0 0 10px; padding-left: 22px; }
.answer-body h3, .answer-body h4 { margin: 14px 0 6px; font-size: 16px; }
.answer-body code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 0.9em; }
.answer-body pre { background: var(--surface-2); padding: 12px; border-radius: 10px; overflow-x: auto; }
.answer-body pre code { background: none; padding: 0; }
.cite {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px;
  padding: 0 5px; margin: 0 1px; border-radius: 6px; background: var(--accent-soft); color: var(--accent);
  font-size: 11px; font-weight: 700; vertical-align: 2px; text-decoration: none !important;
}
.cursor::after { content: "▍"; color: var(--accent); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.answer-error { color: var(--err); font-size: 14px; }
.sources-row { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 0; scrollbar-width: thin; }
.source-pill {
  flex: none; display: flex; align-items: center; gap: 6px; max-width: 220px;
  border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; font-size: 12.5px; color: var(--text);
  background: var(--surface-2);
}
.source-pill:hover { text-decoration: none; border-color: var(--accent); }
.source-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-pill b { color: var(--accent); }
.related { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 12px; }
.related h3 { font-size: 13px; color: var(--muted); margin: 0 0 6px; font-weight: 600; }
.related button {
  display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text);
  padding: 7px 0; border-bottom: 1px dashed var(--border);
}
.related button:last-child { border-bottom: 0; }
.related button:hover { color: var(--accent); }
.skeleton { height: 12px; border-radius: 6px; background: var(--surface-2); margin: 10px 0; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* Results */
.meta-line { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.result { padding: 4px 0 20px; }
.result .site { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.result .site img { width: 18px; height: 18px; border-radius: 4px; background: var(--surface-2); }
.result h3 { margin: 3px 0 4px; font-size: 18px; font-weight: 600; line-height: 1.35; }
.result h3 a { color: var(--text); }
.result h3 a:hover { color: var(--accent); }
.result p { margin: 0; color: var(--muted); font-size: 14.5px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.badge { font-size: 11px; border-radius: 6px; padding: 1px 7px; background: var(--surface-2); color: var(--muted); }
.badge.boost { background: var(--accent-soft); color: var(--accent); }

.empty { color: var(--muted); padding: 30px 0; }
footer.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 20px; }
