:root {
  --bg: #0b0e14;
  --bg2: #0f131c;
  --panel: #131824;
  --panel2: #1a2130;
  --line: #232b3d;
  --text: #e6eaf2;
  --muted: #8b94a8;
  --accent: #5b8cff;
  --good: #34d399;
  --warn: #fbbf24;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at 80% -10%, #16203a 0%, var(--bg) 55%) fixed;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* header */
header {
  display: flex; align-items: center; gap: 18px; padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 19, 28, 0.85);
  backdrop-filter: blur(10px);
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: 14px; letter-spacing: .5px;
  background: linear-gradient(135deg, #5b8cff, #a855f7);
  box-shadow: 0 6px 18px rgba(91, 140, 255, .35);
}
h1 { font-size: 16px; margin: 0; font-weight: 650; letter-spacing: .2px; }
.sub { font-size: 12px; color: var(--muted); }
.searchwrap { flex: 1; max-width: 560px; }
#search {
  width: 100%; padding: 9px 14px; border-radius: 10px; font-size: 13px;
  color: var(--text); background: var(--panel); border: 1px solid var(--line); outline: none;
}
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,140,255,.15); }
.actions { display: flex; gap: 8px; margin-left: auto; }
button {
  padding: 8px 13px; border-radius: 9px; font-size: 12.5px; cursor: pointer;
  color: var(--text); background: var(--panel2); border: 1px solid var(--line);
  transition: background .15s, border-color .15s, transform .05s;
}
button:hover { background: #222b3d; border-color: #33405a; }
button:active { transform: translateY(1px); }

/* ---- filter bar ---- */
#filterbar {
  display: flex; gap: 16px; align-items: flex-start; padding: 10px 20px;
  border-bottom: 1px solid var(--line); background: rgba(15,19,28,.7);
  backdrop-filter: blur(8px); flex-wrap: wrap;
}
.fgroup { display: flex; align-items: center; gap: 8px; }
.fgroup.tags { flex: 1; min-width: 320px; flex-wrap: wrap; }
.fgroup.controls { margin-left: auto; }
.flabel { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
#tagsearch {
  width: 130px; padding: 6px 10px; border-radius: 8px; font-size: 12px;
  color: var(--text); background: var(--panel); border: 1px solid var(--line); outline: none;
}
#tagsearch:focus { border-color: var(--accent); }
select {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 9px; font-size: 12px; outline: none;
}
#tagchips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 62px; overflow-y: auto; }
.tagchip {
  font-size: 11.5px; padding: 4px 10px; border-radius: 999px; cursor: pointer;
  background: var(--panel2); border: 1px solid var(--line); color: #c7d0e2; white-space: nowrap;
}
.tagchip:hover { border-color: var(--accent); color: #fff; }
.tagchip.active { background: #2b3f77; border-color: #5b8cff; color: #fff; font-weight: 600; }
.tagchip .n { color: var(--muted); font-size: 10.5px; margin-left: 4px; }
.tagchip.active .n { color: #cfe0ff; }
#clearfilters { padding: 6px 12px; font-size: 12px; }
.toggle { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--accent); }

/* layout */
main { flex: 1; display: flex; min-height: 0; position: relative; }

/* ---- changelog drawer ---- */
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: 420px; max-width: 90vw;
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border-left: 1px solid var(--line); box-shadow: -18px 0 40px rgba(0,0,0,.45);
  display: flex; flex-direction: column; z-index: 20;
}
.drawer.hidden { display: none; }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; border-bottom: 1px solid var(--line); font-weight: 650;
}
.drawer-head button { padding: 4px 10px; }
.drawer-filters { display: flex; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
#changelog-list { overflow-y: auto; padding: 10px 12px 40px; }
.cl-entry {
  padding: 9px 10px; border-radius: 9px; border: 1px solid transparent; cursor: pointer;
}
.cl-entry:hover { background: #1b2230; border-color: var(--line); }
.cl-entry .cl-top { display: flex; align-items: baseline; gap: 8px; }
.cl-entry .cl-date { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.cl-entry .cl-name { font-size: 13px; color: #dbe4f5; font-weight: 550; }
.cl-entry .cl-action {
  margin-left: auto; font-size: 10px; padding: 1px 7px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
}
.cl-entry .cl-action.add { color: #6ee7b7; border-color: #1f5c46; }
.cl-entry .cl-action.update { color: #93c5fd; border-color: #274a7c; }
.cl-entry .cl-action.score { color: #fdba74; border-color: #7c3f14; }
.cl-entry .cl-action.delete { color: #fca5a5; border-color: #7c2626; }
.cl-entry .cl-cats { font-size: 11px; color: var(--muted); margin-top: 3px; }
.cl-entry .cl-src { font-size: 10px; color: #5f6b83; margin-top: 2px; }

/* ---- left: tree ---- */
#tree {
  width: 330px; flex: none; border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  overflow-y: auto; padding: 12px 8px 40px;
}
#loading { color: var(--muted); padding: 20px; text-align: center; }
.tnode {
  display: flex; align-items: center; gap: 7px; padding: 5px 8px; border-radius: 7px;
  cursor: pointer; user-select: none; white-space: nowrap;
}
.tnode:hover { background: #1b2230; }
.tnode.selected { background: #223055; box-shadow: inset 0 0 0 1px #3b5bd0; }
.tnode .twisty {
  width: 14px; flex: none; text-align: center; color: var(--muted); font-size: 10px;
  transition: transform .15s;
}
.tnode .twisty.open { transform: rotate(90deg); }
.tnode .twisty.leaf { opacity: 0; }
.tnode .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tnode .tname { overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.tnode.depth0 .tname { font-weight: 650; }
.tnode.depth1 .tname { font-weight: 550; }
.tnode .tcount {
  margin-left: auto; font-size: 10.5px; color: var(--muted); background: #1b2230;
  border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; flex: none;
}
.tnode.matched .tname { color: #fff; }
.tnode.dim { opacity: .35; }

/* ---- middle: results ---- */
#results { flex: 1; min-width: 0; overflow-y: auto; padding: 22px 26px 60px; }
#results-header h2 { font-size: 22px; margin: 0 0 6px; }
#results-header .desc { color: #b6c0d4; font-size: 13.5px; margin-bottom: 4px; max-width: 780px; }
.crumbs { font-size: 11.5px; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--muted); cursor: pointer; }
.crumbs a:hover { color: var(--accent); }
.section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  margin: 22px 0 12px; display: flex; justify-content: space-between; align-items: baseline;
}
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 4px; }
.chip {
  font-size: 12px; padding: 6px 11px; border-radius: 999px; cursor: pointer;
  background: var(--panel2); border: 1px solid var(--line); color: #c7d0e2;
}
.chip:hover { border-color: var(--accent); color: #fff; }
.chip .c { color: var(--muted); font-size: 11px; }

#cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.tool {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 15px; transition: border-color .15s, transform .1s; display: flex; flex-direction: column;
}
.tool:hover { border-color: #3a4763; transform: translateY(-1px); }
.tool-head { display: flex; align-items: baseline; gap: 8px; }
.tool-head a { color: #dbe4f5; font-weight: 640; font-size: 15px; text-decoration: none; }
.tool-head a:hover { color: var(--accent); text-decoration: underline; }
.tool-head .score { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; }
.tool-desc { color: #9aa5ba; font-size: 12.5px; margin: 6px 0 10px; }
.tool-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.pill {
  font-size: 10.5px; padding: 2px 8px; border-radius: 999px;
  background: #202a3d; color: #aab6cd; border: 1px solid #2b364d;
}
.pill.pricing { text-transform: capitalize; color: var(--good); border-color: #1f4a3a; }
.bar { height: 5px; border-radius: 4px; background: #232c3f; overflow: hidden; margin-top: auto; }
.bar .fill { height: 100%; border-radius: 4px; }
.matched { font-size: 10.5px; color: var(--muted); margin-top: 8px; }
.meta-line { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11px; color: var(--muted); margin-top: 9px; }
.meta-line .k { color: #cfd8ea; font-variant-numeric: tabular-nums; }
.ghlink { color: #8fb0ff; text-decoration: none; }
.ghlink:hover { color: #b9cdff; text-decoration: underline; }
.hot-stat { color: #fb923c; font-variant-numeric: tabular-nums; }
.badge {
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.badge.hot { background: rgba(251,146,60,.15); color: #fdba74; border-color: #7c3f14; }
.badge.new { background: rgba(52,211,153,.14); color: #6ee7b7; border-color: #1f5c46; }
.pill.tag { cursor: pointer; }
.pill.tag:hover { border-color: var(--accent); color: #fff; }
.empty { color: var(--muted); font-size: 13.5px; font-style: italic; }

/* footer */
footer {
  display: flex; gap: 16px; align-items: center; padding: 7px 18px;
  border-top: 1px solid var(--line); font-size: 11px; color: var(--muted);
  background: rgba(15,19,28,.9);
}
footer code { background: #1a2130; padding: 1px 6px; border-radius: 5px; color: #9fb0cf; }
footer a { color: var(--accent); text-decoration: none; }
footer #foot-meta { margin-left: auto; }

/* scrollbars */
#tree::-webkit-scrollbar, #results::-webkit-scrollbar { width: 9px; }
#tree::-webkit-scrollbar-thumb, #results::-webkit-scrollbar-thumb { background: #2a3346; border-radius: 9px; }

@media (max-width: 820px) {
  main { flex-direction: column; }
  #tree { width: auto; max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .actions { display: none; }
}
