:root {
  --bg:        #faf8f5;
  --surface:   #ffffff;
  --ink:       #1a1714;
  --ink-soft:  #8a847c;
  --line:      #efe9e1;
  --accent:    #e4572e;
  --accent-soft:#fbeae3;
  --link:      #1a5fb4;
  --link-visited:#7b3fa0;
  --url-green: #3a7d44;
  --shadow: 0 1px 2px rgba(26,23,20,.04), 0 8px 24px -16px rgba(26,23,20,.18);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.5;
  -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased;
  min-height: 100vh; display: flex; flex-direction: column;
}
::selection { background: var(--accent); color: #fff; }
a { color: inherit; text-decoration: none; }

body[data-mode="home"]    .results-header { display: none; }
body[data-mode="results"] .home-hero      { display: none; }

/* ═══════ HOME ═══════ */
.home-hero {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 20px 80px; text-align: center; min-height: 78vh;
}
.home-logo {
  display: flex; align-items: center; gap: 14px; margin-bottom: 18px;
  animation: rise .7s cubic-bezier(.2,.7,.2,1) backwards;
}
.logo-mark {
  width: 64px; height: 64px; border-radius: 20px;
  background: linear-gradient(140deg, var(--accent), #f0853f);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 12px 28px -10px rgba(228,87,46,.55);
}
.logo-word {
  font-family: 'Fraunces', serif; font-weight: 600;
  font-size: clamp(36px, 9vw, 56px); letter-spacing: -0.03em; color: var(--ink);
}
.logo-word em { font-style: italic; color: var(--accent); }
.home-tagline { color: var(--ink-soft); font-size: 15px; margin-bottom: 26px; animation: rise .7s cubic-bezier(.2,.7,.2,1) backwards .05s; }
.home-search { width: 100%; max-width: 580px; animation: rise .7s cubic-bezier(.2,.7,.2,1) backwards .1s; }
.home-meta {
  display: inline-flex; gap: 8px; align-items: center;
  margin-top: 24px; font-size: 13px; color: var(--ink-soft);
  animation: rise .7s cubic-bezier(.2,.7,.2,1) backwards .15s;
}
.home-meta .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #6cb56c; box-shadow: 0 0 0 4px rgba(108,181,108,.18);
}
.home-meta.warn .dot { background: #d3853a; box-shadow: 0 0 0 4px rgba(211,133,58,.18); }
.home-meta.err  .dot { background: #c43c3c; box-shadow: 0 0 0 4px rgba(196,60,60,.18); }

/* ═══════ SEARCHBAR ═══════ */
.searchbar {
  display: flex; align-items: center; gap: 13px;
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: 999px; padding: 0 18px; height: 56px;
  box-shadow: var(--shadow);
  transition: border-color .22s, box-shadow .22s;
  position: relative;
}
.searchbar.focused { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); }
.searchbar .ico-search { color: var(--ink-soft); flex-shrink: 0; display: grid; place-items: center; transition: color .2s; }
.searchbar.focused .ico-search { color: var(--accent); }
.searchbar input {
  flex: 1; border: none; outline: none; background: transparent;
  font-family: 'Outfit'; font-size: 17px; font-weight: 500; color: var(--ink); min-width: 0;
}
.searchbar input::placeholder { color: var(--ink-soft); font-weight: 400; }
.btn-clear {
  border: none; background: var(--line); color: var(--ink-soft);
  width: 30px; height: 30px; border-radius: 50%;
  display: none; place-items: center; cursor: pointer; flex-shrink: 0;
  transition: background .18s, transform .18s;
}
.btn-clear.show { display: grid; }
.btn-clear:active { transform: scale(.86); background: #e6ddd2; }

/* ═══════ AUTOCOMPLETE ═══════ */
.suggest {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 18px;
  box-shadow: 0 12px 32px -12px rgba(26,23,20,.28); overflow: hidden;
  z-index: 30; display: none; text-align: left;
}
.suggest.show { display: block; animation: pop .22s cubic-bezier(.2,.7,.2,1); }
.suggest-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px 8px; font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft);
}
.suggest-clear { border: none; background: none; color: var(--ink-soft); font-family: 'Outfit'; font-size: 12px; font-weight: 600; cursor: pointer; padding: 3px 6px; border-radius: 6px; }
.suggest-clear:hover { color: var(--accent); }
.suggest-item {
  display: flex; align-items: center; gap: 13px; padding: 11px 18px; cursor: pointer;
  transition: background .14s;
}
.suggest-item:hover, .suggest-item.kbd { background: var(--bg); }
.suggest-ico { color: var(--ink-soft); display: grid; place-items: center; flex-shrink: 0; }
.suggest-text { flex: 1; font-size: 15.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest-text b { font-weight: 700; color: var(--accent); }
.suggest-del {
  border: none; background: none; color: var(--ink-soft); width: 34px; height: 34px; border-radius: 8px;
  display: grid; place-items: center; cursor: pointer; flex-shrink: 0; transition: color .15s, transform .15s;
}
.suggest-del:hover { color: var(--accent); }
.suggest-del:active { transform: scale(.85); }
.suggest-tag { font-size: 11px; font-weight: 600; color: var(--ink-soft); flex-shrink: 0; }

/* ═══════ RESULTS HEADER ═══════ */
.results-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(250,248,245,.9);
  backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.rh-top {
  display: flex; align-items: center; gap: 18px;
  padding: 14px 24px; max-width: 1000px; margin: 0 auto;
}
.rh-logo { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.rh-logo .logo-mark { width: 38px; height: 38px; border-radius: 11px; }
.rh-logo .logo-word { font-size: 22px; }
.rh-search { flex: 1; max-width: 560px; position: relative; }
.rh-search .searchbar { height: 48px; }

.rh-tabs {
  display: flex; gap: 4px; padding: 0 24px; max-width: 1000px; margin: 0 auto;
  overflow-x: auto; scrollbar-width: none;
}
.rh-tabs::-webkit-scrollbar { display: none; }
.rh-tab {
  padding: 11px 14px 13px; font-size: 14px; font-weight: 500; color: var(--ink-soft);
  border-bottom: 2.5px solid transparent; cursor: pointer; white-space: nowrap;
  transition: color .18s, border-color .18s;
}
.rh-tab:hover { color: var(--ink); }
.rh-tab.active { color: var(--accent); border-color: var(--accent); font-weight: 600; }

/* ═══════ RESULTS ═══════ */
.results-wrap { flex: 1; max-width: 1000px; width: 100%; margin: 0 auto; padding: 22px 24px 60px; }
.results-stats { font-size: 13px; color: var(--ink-soft); margin: 4px 4px 22px; }
.results-stats b { color: var(--ink); font-weight: 600; }
.results-stats .badge {
  display: inline-block; margin-left: 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  background: var(--accent-soft); color: var(--accent);
  padding: 2px 8px; border-radius: 999px; vertical-align: 1px;
}

.result {
  max-width: 620px; margin-bottom: 26px;
  animation: rise .4s cubic-bezier(.2,.7,.2,1) backwards;
}
.result-site { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; }
.result-favicon {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700;
}
.result-sitemeta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.result-sitename { font-size: 14px; font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-url { font-size: 12.5px; color: var(--url-green); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-title {
  font-family: 'Outfit'; font-size: 21px; font-weight: 500; line-height: 1.3;
  color: var(--link); margin-bottom: 5px; display: inline-block;
  transition: color .15s;
}
.result-title:hover { text-decoration: underline; }
.result a:visited .result-title { color: var(--link-visited); }
.result-snippet { font-size: 14.5px; color: #4a443d; line-height: 1.6; }
.result-snippet b { font-weight: 600; }
.result-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.result-tag {
  font-size: 12.5px; color: var(--link); background: var(--surface);
  border: 1px solid var(--line); padding: 4px 11px; border-radius: 8px;
  transition: border-color .15s;
}
.result-tag:hover { border-color: var(--link); }

/* Skeleton loader */
.skeleton .sk-line { display: block; height: 14px; border-radius: 6px; background: linear-gradient(90deg,#eee,#f6f1eb,#eee); background-size: 200% 100%; animation: shimmer 1.2s infinite; margin-bottom: 8px; }
.skeleton .sk-line.title { height: 22px; width: 80%; margin-top: 4px; }
.skeleton .sk-line.url   { width: 200px; height: 12px; }
.skeleton .sk-line.short { width: 60%; }
.skeleton .sk-block { margin-bottom: 26px; max-width: 620px; }

/* Pagination */
.pager { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 28px; }
.pager a, .pager span {
  min-width: 38px; height: 38px; padding: 0 12px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; font-weight: 500; color: var(--ink);
  background: var(--surface); transition: border-color .15s, color .15s;
}
.pager a:hover { border-color: var(--accent); color: var(--accent); }
.pager .current { border-color: var(--accent); color: var(--accent); font-weight: 600; cursor: default; }
.pager .disabled { color: var(--ink-soft); border-color: var(--line); cursor: not-allowed; opacity: .5; }

/* Empty / Error */
.empty { text-align: center; color: var(--ink-soft); padding: 70px 30px; line-height: 1.6; max-width: 500px; margin: 0 auto; }
.empty-ico { width: 68px; height: 68px; margin: 0 auto 18px; border-radius: 22px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.empty p { font-size: 15px; }

/* ═══════ FOOTER ═══════ */
.site-footer { background: var(--surface); border-top: 1px solid var(--line); font-size: 13.5px; color: var(--ink-soft); }
.footer-top { padding: 14px 24px; border-bottom: 1px solid var(--line); }
.footer-top span { max-width: 1000px; margin: 0 auto; display: block; }
.footer-bottom {
  max-width: 1000px; margin: 0 auto; padding: 16px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.footer-links { display: flex; gap: 22px; flex-wrap: wrap; }
.footer-links a { color: var(--ink-soft); transition: color .18s; }
.footer-links a:hover { color: var(--accent); }

@media (max-width: 680px) {
  .rh-top { gap: 12px; padding: 12px 16px; }
  .rh-logo .logo-word { display: none; }
  .results-wrap { padding: 18px 16px 50px; }
  .result-title { font-size: 19px; }
  .footer-bottom { flex-direction: column; align-items: flex-start; gap: 12px; }
}

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop  { from { opacity: 0; transform: scale(.97) translateY(-4px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
