:root {
  --bg: #08090a;
  --surface: #0f1011;
  --surface-2: #141517;
  --border: #1e1f22;
  --border-hi: #2a2c30;
  --text: #ececf1;
  --text-2: #a1a1a8;
  --text-3: #6b6b74;
  --accent: #3b82f6;
  --accent-hi: #60a5fa;
  --defensive: #60a5fa;
  --offensive: #ef4444;
  --neutral: #a78bfa;
  --ok: #22c55e;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@supports (font-variation-settings: normal) { :root { --font-sans: "InterVariable", "Inter", sans-serif; } }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--font-sans); font-size: 14px; line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
.container { max-width: 1120px; margin: 0 auto; padding: 0 32px; }

/* nav */
nav.top {
  border-bottom: 1px solid var(--border);
  background: rgba(8, 9, 10, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  height: 56px;
  flex-shrink: 0;
}
nav.top .row { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { font-weight: 600; letter-spacing: -.01em; font-size: 14px; display: inline-flex; align-items: center; gap: 10px; }
.brand .dot { width: 8px; height: 8px; background: var(--accent); border-radius: 2px; }
.nav-links { display: flex; gap: 28px; font-size: 13.5px; color: var(--text-2); }
.nav-links a { transition: color .15s; }
.nav-links a:hover, .nav-links a.active { color: var(--text); }
.nav-cta {
  background: var(--text); color: var(--bg);
  padding: 6px 14px; border-radius: 6px;
  font-size: 13px; font-weight: 500;
  transition: opacity .15s;
}
.nav-cta:hover { opacity: 0.9; }

/* shell */
.lib-shell {
  display: grid;
  grid-template-columns: 400px 1fr;
  height: calc(100vh - 56px);
  overflow: hidden;
}
.lib-left {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden; min-width: 0;
  background: var(--bg);
}
.lib-right { display: flex; flex-direction: column; overflow: hidden; min-width: 0; background: var(--bg); }

/* search */
.lib-header { flex: 0 0 auto; padding: 20px 20px 12px; border-bottom: 1px solid var(--border); }
.search-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-3);
  transition: border-color .15s, background .15s;
}
.search-wrap:focus-within { border-color: var(--border-hi); background: var(--surface-2); }
.search-wrap input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-family: var(--font-mono); font-size: 13px;
}
.search-wrap input::placeholder { color: var(--text-3); }

.chip-row { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.chip {
  padding: 4px 11px; border: 1px solid var(--border);
  background: transparent; color: var(--text-2);
  border-radius: 100px; font-size: 11.5px; font-family: var(--font-mono);
  cursor: pointer; font-weight: 500; letter-spacing: 0.01em;
  transition: all .15s;
}
.chip:hover { color: var(--text); border-color: var(--border-hi); }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip[data-cat="defensive"].active { background: var(--defensive); border-color: var(--defensive); color: #0a0a0a; }
.chip[data-cat="offensive"].active { background: var(--offensive); border-color: var(--offensive); color: #0a0a0a; }
.chip[data-cat="neutral"].active   { background: var(--neutral); border-color: var(--neutral); color: #0a0a0a; }

.lib-count { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); margin-top: 12px; letter-spacing: 0.02em; }

/* list */
.lib-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.lib-row {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background-color .1s, border-color .1s;
}
.lib-row:hover { background: var(--surface); }
.lib-row.active { background: var(--surface-2); }
.lib-row.category-defensive.active { border-left-color: var(--defensive); }
.lib-row.category-offensive.active { border-left-color: var(--offensive); }
.lib-row.category-neutral.active   { border-left-color: var(--neutral); }
.lib-row.category-defensive:hover  { border-left-color: rgba(96, 165, 250, 0.35); }
.lib-row.category-offensive:hover  { border-left-color: rgba(239, 68, 68, 0.35); }
.lib-row.category-neutral:hover    { border-left-color: rgba(167, 139, 250, 0.35); }

.lib-row .lname {
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  color: var(--text); margin-bottom: 4px; letter-spacing: -.005em;
}
.lib-row .ldesc {
  font-size: 12.5px; color: var(--text-2); line-height: 1.5;
  margin-bottom: 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 34px;
}
.lib-row .lmeta {
  display: flex; gap: 8px; align-items: center;
  font-size: 11px; color: var(--text-3);
  font-family: var(--font-mono);
}
.lm-dot { color: var(--text-3); opacity: 0.5; }
.lscore { margin-left: auto; color: var(--accent-hi); font-weight: 600; }

.lib-empty {
  padding: 60px 20px; text-align: center;
  color: var(--text-3); font-size: 13px;
  font-family: var(--font-mono);
}

/* trust badges */
.badge-trust {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 2px 7px; border-radius: 3px;
  font-family: var(--font-mono);
}
.badge-community { background: rgba(161, 161, 168, 0.1); color: var(--text-2); }
.badge-professional { background: rgba(96, 165, 250, 0.12); color: var(--accent-hi); }
.badge-verified { background: rgba(34, 197, 94, 0.12); color: var(--ok); }
.badge-restricted { background: rgba(239, 68, 68, 0.12); color: var(--offensive); }

/* detail */
.lib-detail { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 40px 48px; }
.lib-detail-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; text-align: center; gap: 8px;
}
.empty-glyph { color: var(--border-hi); font-size: 42px; line-height: 1; margin-bottom: 8px; }
.empty-text { font-size: 15px; color: var(--text-2); }
.empty-hint { font-size: 13px; color: var(--text-3); max-width: 320px; line-height: 1.55; }

.lib-detail .dcrumb {
  font-family: var(--font-mono); font-size: 11.5px;
  color: var(--text-3); margin-bottom: 14px;
  letter-spacing: 0.02em;
}
.lib-detail .dcrumb a { color: var(--text-2); }
.lib-detail .dcrumb a:hover { color: var(--accent-hi); }

.lib-title-row {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.lib-detail h1 {
  font-family: var(--font-mono); font-size: 24px; font-weight: 600;
  letter-spacing: -.015em; margin: 0; color: var(--text);
  display: flex; align-items: baseline; gap: 8px;
}
.lib-detail h1 .ver { color: var(--text-3); font-size: 14px; font-weight: 400; }
.lib-title-row .cat-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.lib-title-row .cat-tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; }
.lib-title-row .cat-tag.defensive { color: var(--defensive); }
.lib-title-row .cat-tag.defensive::before { background: var(--defensive); box-shadow: 0 0 8px rgba(96,165,250,0.5); }
.lib-title-row .cat-tag.offensive { color: var(--offensive); }
.lib-title-row .cat-tag.offensive::before { background: var(--offensive); box-shadow: 0 0 8px rgba(239,68,68,0.5); }
.lib-title-row .cat-tag.neutral { color: var(--neutral); }
.lib-title-row .cat-tag.neutral::before { background: var(--neutral); box-shadow: 0 0 8px rgba(167,139,250,0.5); }

.lib-detail .ddesc {
  color: var(--text-2); font-size: 15px; line-height: 1.6;
  margin: 0 0 32px; max-width: 720px;
}

.lib-detail .kv {
  display: grid; grid-template-columns: 120px 1fr;
  gap: 10px 20px; font-size: 13px; margin-bottom: 32px;
}
.lib-detail .kv .k {
  color: var(--text-3); text-transform: uppercase;
  font-size: 10.5px; letter-spacing: 0.1em; font-weight: 600;
  padding-top: 3px; font-family: var(--font-mono);
}
.lib-detail .kv .v {
  color: var(--text); font-family: var(--font-mono); font-size: 12.5px;
  word-break: break-word;
}

.lib-install-msg {
  font-family: var(--font-mono); font-size: 12px;
  min-height: 18px; margin-bottom: 8px; color: var(--text-3);
}

.lib-detail .section {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-3); font-weight: 600;
  margin: 32px 0 12px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
}

.lib-detail pre {
  background: var(--surface); padding: 18px 20px;
  border-radius: 8px; font-family: var(--font-mono);
  font-size: 12px; color: var(--text-2);
  overflow: auto; max-height: 380px;
  line-height: 1.65; border: 1px solid var(--border);
  margin: 0;
}

.lib-code {
  height: 380px; border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden;
  background: var(--bg);
}

/* buttons in detail */
.btn-install {
  margin-left: auto;
  padding: 8px 16px; border-radius: 6px; border: none;
  background: var(--text); color: var(--bg);
  font-family: var(--font-sans); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: opacity .15s, transform .1s;
}
.btn-install:hover { opacity: 0.92; }
.btn-install:active { transform: translateY(1px); }
.btn-install:disabled { opacity: 0.6; cursor: default; }
.btn-install.installed { background: var(--ok); color: #062a10; }

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 5px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--border-hi); }
