:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --card-hover: #fbfcfe;
  --text: #14161a;
  --muted: #6b7280;
  --line: #e4e7ec;
  --accent: #2563eb;
  --accent-soft: #e8efff;
  --good: #15803d;
  --good-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fdf1de;
  --bad: #b91c1c;
  --bad-soft: #fdeaea;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1014;
    --card: #171a20;
    --card-hover: #1c2028;
    --text: #e8eaef;
    --muted: #98a1b0;
    --line: #262b34;
    --accent: #6ea8fe;
    --accent-soft: #1b2537;
    --good: #6ee7a8;
    --good-soft: #14261d;
    --warn: #fbbf5c;
    --warn-soft: #2a2115;
    --bad: #fca5a5;
    --bad-soft: #2b1a1a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

/* display в правилах ниже перебивает браузерный [hidden] — возвращаем приоритет */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

/* ── шапка ─────────────────────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  flex: none;
}
.brand-mark svg { width: 22px; height: 22px; }

h1 { font-size: 21px; margin: 0; letter-spacing: -.01em; }
.subtitle { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.counter {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

/* ── поиск ─────────────────────────────────────────────── */

.searchbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 44px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.searchbar:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow), 0 0 0 3px var(--accent-soft);
}

.searchbar-icon {
  position: absolute;
  left: 15px;
  display: grid;
  place-items: center;
  color: var(--muted);
  pointer-events: none;
}
.searchbar-icon svg { width: 18px; height: 18px; }

#query {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 16px;
  padding: 8px 0;
  outline: none;
}
#query::-webkit-search-cancel-button { display: none; }

button { font: inherit; cursor: pointer; }

.primary {
  border: 0;
  border-radius: 10px;
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  transition: filter .15s;
}
.primary:hover { filter: brightness(1.08); }
@media (prefers-color-scheme: dark) { .primary { color: #0e1014; } }

.ghost {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 14px;
  background: var(--card);
  color: var(--text);
  transition: background .15s, border-color .15s;
}
.ghost:hover { background: var(--card-hover); border-color: var(--accent); }

.clear {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 15px;
  padding: 6px 8px;
  border-radius: 8px;
}
.clear:hover { color: var(--text); background: var(--bg); }

/* ── строка вывода ─────────────────────────────────────── */

.meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 2px 12px;
}

.verdict {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}
.verdict[data-level="exact"], .verdict[data-level="high"] { background: var(--good-soft); color: var(--good); }
.verdict[data-level="medium"] { background: var(--warn-soft); color: var(--warn); }
.verdict[data-level="low"], .verdict[data-level="none"] { background: var(--bad-soft); color: var(--bad); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 12px;
}

/* ── результаты ────────────────────────────────────────── */

.results { display: flex; flex-direction: column; gap: 10px; }

.card {
  display: grid;
  grid-template-columns: 34px 1fr;
  column-gap: 14px;
  padding: 13px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .15s, background .15s;
}
.card:hover { background: var(--card-hover); border-color: var(--accent); }
.card.top { border-color: var(--accent); box-shadow: var(--shadow); }

.rank {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.card.top .rank { background: var(--accent-soft); color: var(--accent); }

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 34px;
}

.name { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.pid { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 6px; }

.side { display: flex; align-items: center; gap: 10px; flex: none; }

.score { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); }
.bar {
  width: 64px; height: 5px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.bar span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }

.pick {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  border-radius: 9px;
  padding: 6px 12px;
  font-size: 13px;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.pick:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .pick:hover { color: #0e1014; } }
.pick[disabled] { opacity: .5; cursor: default; }

.tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
.tag {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.tag.via { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.kind { color: var(--muted); }

/* ── пустые состояния ──────────────────────────────────── */

.empty {
  padding: 48px 24px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty-title { margin: 0 0 6px; font-weight: 600; }
.empty-hint { margin: 0; color: var(--muted); font-size: 13px; }

kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--card);
  font: 12px/1.4 ui-monospace, "Cascadia Code", Consolas, monospace;
}

.footer { margin-top: 28px; text-align: center; color: var(--muted); font-size: 12px; }

/* ── панель синонимов ──────────────────────────────────── */

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(420px, 100%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  padding: 22px;
  background: var(--card);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow-y: auto;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-head h2 { font-size: 17px; margin: 0; }
.drawer-hint { color: var(--muted); font-size: 13px; margin: 8px 0 16px; }

.syn-list { display: flex; flex-direction: column; gap: 8px; }

.syn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.syn b { font-weight: 600; }
.syn small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.syn button {
  border: 0;
  background: none;
  color: var(--muted);
  padding: 4px 6px;
  border-radius: 6px;
}
.syn button:hover { color: var(--bad); background: var(--bad-soft); }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(9, 11, 15, .45);
}

/* ── уведомление ───────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 30;
  padding: 11px 18px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  box-shadow: var(--shadow);
}

@media (max-width: 640px) {
  .page { padding: 20px 14px 48px; }
  .searchbar { flex-wrap: wrap; padding-left: 40px; }
  .card { grid-template-columns: 30px 1fr; }
  .head { flex-wrap: wrap; }
  .bar { display: none; }
}
