:root {
  --bg: #0b0b0d; --bg-elev: #151518; --bg-card: #16161a; --bg-hover: #1d1d22;
  --border: #26262c; --border-strong: #34343c;
  --text: #ededf0; --text-dim: #a0a0aa; --text-faint: #6b6b75;
  --accent: #e0623a; --accent-soft: rgba(224,98,58,.14);
  --green: #3fb950; --blue: #58a6ff; --yellow: #d29922; --purple: #a371f7;
  --radius: 12px; --radius-sm: 8px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --maxw: 1240px;
}
[data-theme="light"] {
  --bg: #fafafa; --bg-elev: #fff; --bg-card: #fff; --bg-hover: #f3f3f5;
  --border: #e7e7ea; --border-strong: #d6d6db;
  --text: #16161a; --text-dim: #55555f; --text-faint: #8a8a93;
  --accent: #c2410c; --accent-soft: rgba(194,65,12,.10);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }

/* Nav */
.nav { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 18px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); padding: 12px 24px; }
.brand { font-weight: 700; font-size: 17px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); }
.nav-links { display: flex; align-items: center; gap: 14px; }
.nav-links a { color: var(--text-dim); font-weight: 500; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-search { flex: 1; max-width: 460px; }
.nav-search input { width: 100%; background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
  padding: 8px 14px; border-radius: 999px; font-size: 14px; outline: none; }
.nav-search input:focus { border-color: var(--accent); }
.nav-right { margin-left: auto; }
#theme-toggle { background: var(--bg-elev); border: 1px solid var(--border); color: var(--text-dim);
  width: 36px; height: 36px; border-radius: 999px; cursor: pointer; font-size: 16px; }
#theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }

/* Layout */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 24px; }
.footer { max-width: var(--maxw); margin: 40px auto 0; padding: 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; gap: 12px; color: var(--text-faint); font-size: 13px; }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--bg-elev); border: 1px solid var(--border); color: var(--text-dim);
  padding: 5px 12px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 500; }
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip .n { color: var(--text-faint); margin-left: 5px; font-weight: 400; }
select.sort { background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
  padding: 6px 10px; border-radius: var(--radius-sm); font-size: 13px; cursor: pointer; }
.spacer { flex: 1; }

/* Collapsible classification filters (language / asset class / function) */
.filter-panel { display: flex; flex-direction: column; gap: 10px; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 18px; }
.frow { display: flex; align-items: flex-start; gap: 12px; }
.frow .flabel { color: var(--text-faint); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  font-weight: 600; width: 78px; flex-shrink: 0; padding-top: 6px; }
.chip.clear { margin-top: 2px; color: var(--accent); border-color: var(--accent); align-self: flex-start; }

/* Grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; cursor: pointer; transition: border-color .12s, background .12s, transform .12s; display: flex; flex-direction: column; gap: 10px; }
.card:hover { border-color: var(--border-strong); background: var(--bg-hover); transform: translateY(-1px); }
.card-head { display: flex; align-items: baseline; gap: 8px; }
.card-name { font-weight: 600; font-size: 15.5px; color: var(--text); line-height: 1.3; }
.card-author { color: var(--text-dim); font-size: 13px; }
.card-desc { color: var(--text-dim); font-size: 13.5px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; flex: 1; }
.card-foot { display: flex; align-items: center; gap: 14px; font-size: 12.5px; color: var(--text-faint); }
.stat { display: inline-flex; align-items: center; gap: 4px; }
.badge-src { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.b-skillhub { background: rgba(63,185,80,.16); color: var(--green); }
.b-clawhub { background: rgba(88,166,255,.16); color: var(--blue); }
.b-github { background: rgba(163,113,247,.16); color: var(--purple); }
.b-skillsmp { background: rgba(210,153,34,.16); color: var(--yellow); }
.badge-multi { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.badge-lang { font-size: 10px; font-weight: 500; padding: 1px 6px; border-radius: 999px; background: var(--bg-hover); color: var(--text-dim); text-transform: uppercase; }
.badge-ac { font-size: 10px; font-weight: 500; padding: 1px 6px; border-radius: 999px; background: rgba(88,166,255,.12); color: var(--blue); }
.badge-noi { font-size: 10px; font-weight: 500; padding: 1px 6px; border-radius: 999px; background: rgba(210,153,34,.14); color: var(--yellow); }
.class-bar { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.class-bar .pill { font-size: 11.5px; }

/* Pagination */
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 26px 0; color: var(--text-dim); }
.pager button { background: var(--bg-elev); border: 1px solid var(--border); color: var(--text); padding: 7px 16px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; }
.pager button:disabled { opacity: .4; cursor: default; }

/* Detail */
.detail { max-width: var(--maxw); margin: 0 auto; padding: 24px; }
.back { color: var(--text-dim); font-size: 13px; margin-bottom: 16px; display: inline-block; }
.back:hover { color: var(--text); text-decoration: none; }
.detail-head { margin-bottom: 6px; }
.detail-name { font-size: 28px; font-weight: 700; line-height: 1.2; margin: 0; }
.detail-sub { display: flex; align-items: center; gap: 12px; margin-top: 8px; color: var(--text-dim); flex-wrap: wrap; }
.detail-desc { color: var(--text); font-size: 15.5px; margin: 18px 0; line-height: 1.6; }
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 28px; margin-top: 8px; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }
.section { margin-top: 26px; }
.section h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); margin: 0 0 12px; font-weight: 600; }

/* File tree */
.tree { font-family: var(--mono); font-size: 12.5px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.tree-file { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--border); cursor: pointer; color: var(--text-dim); }
.tree-file:last-child { border-bottom: none; }
.tree-file:hover { background: var(--bg-hover); color: var(--text); }
.tree-file.active { background: var(--accent-soft); color: var(--accent); }
.tree-file .path { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-file .sz { color: var(--text-faint); font-size: 11px; }
.tree-file .sha { color: var(--text-faint); font-size: 10.5px; }

/* Metadata table */
.meta { width: 100%; border-collapse: collapse; font-size: 13px; }
.meta td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: top; word-break: break-word; }
.meta td.k { color: var(--text-faint); width: 150px; font-weight: 500; white-space: nowrap; }
.meta td.v { color: var(--text); }
.meta td.v.mono { font-family: var(--mono); font-size: 12px; }

/* Source cards (provenance) */
.source-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 10px; background: var(--bg-elev); }
.source-card .sh { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.source-card .meta { margin-top: 6px; }

/* SKILL.md viewer */
/* Rendered SKILL.md — sized DOWN to match the outer UI's type scale (was oversized,
   which made it dominate + feel inconsistent with the surrounding metadata). */
.mdview { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; overflow: auto; max-height: 62vh; font-size: 13px; line-height: 1.6; color: var(--text); }
.mdview h1 { font-size: 15.5px; font-weight: 700; margin: 0 0 8px; line-height: 1.3; }
.mdview h2 { font-size: 13.5px; font-weight: 600; margin: 14px 0 6px; line-height: 1.3; }
.mdview h3 { font-size: 12.5px; font-weight: 600; margin: 12px 0 5px; }
.mdview h1:first-child { margin-top: 0; }
.mdview p { margin: 6px 0; }
.mdview pre { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; overflow: auto; font-family: var(--mono); font-size: 11px; line-height: 1.5; margin: 8px 0; }
.mdview code { font-family: var(--mono); font-size: 11px; background: var(--bg-hover); padding: 1px 4px; border-radius: 3px; }
.mdview pre code { background: none; padding: 0; font-size: inherit; }
.mdview ul, .mdview ol { padding-left: 18px; margin: 6px 0; }
.mdview li { margin: 2px 0; }
.mdview table { border-collapse: collapse; margin: 8px 0; font-size: 11.5px; }
.mdview th, .mdview td { border: 1px solid var(--border); padding: 4px 8px; }
.mdview hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.mdview a { color: var(--accent); }
.mdview img { max-width: 100%; }

/* Eval/safety */
.pill { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--bg-hover); margin: 2px; }
.pill.ok { background: rgba(63,185,80,.16); color: var(--green); }
.dim-list { display: grid; grid-template-columns: 1fr; gap: 6px; }
.dim { display: flex; gap: 8px; font-size: 13px; }
.dim .k { color: var(--text-dim); width: 110px; }

.empty { text-align: center; padding: 60px 20px; color: var(--text-faint); }
.loading { text-align: center; padding: 40px; color: var(--text-dim); }
