/* Toplist AI: màu Unifa (vàng F2CA2A, than 211F22). Tự động/Sáng/Tối qua data-theme. Không CSS inline (CSP style-src 'self'). */
:root {
  --bg: #faf8f3; --surface: #ffffff; --ink: #211f22; --muted: #5d5960; --line: #e4dfd3;
  --accent: #f2ca2a; --accent-ink: #211f22; --link: #7a5a00;
  --mcp: #1f5fbf; --agent: #8a3ab9; --skill: #0f7a55; --tool: #a14a12;
  --lvl-u: #7a7480; --lvl-s: #1f5fbf; --lvl-r: #0f7a55; --warn: #b42318;
  --radius: 10px; --gap: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161517; --surface: #1f1d21; --ink: #f1eee8; --muted: #b3adb7; --line: #34313a;
    --accent: #f2ca2a; --accent-ink: #211f22; --link: #f2ca2a;
    --mcp: #8ab4ff; --agent: #d6a2f5; --skill: #6fd7ad; --tool: #f5a971;
    --lvl-u: #b3adb7; --lvl-s: #8ab4ff; --lvl-r: #6fd7ad; --warn: #ff8a80;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161517; --surface: #1f1d21; --ink: #f1eee8; --muted: #b3adb7; --line: #34313a;
  --accent: #f2ca2a; --accent-ink: #211f22; --link: #f2ca2a;
  --mcp: #8ab4ff; --agent: #d6a2f5; --skill: #6fd7ad; --tool: #f5a971;
  --lvl-u: #b3adb7; --lvl-s: #8ab4ff; --lvl-r: #6fd7ad; --warn: #ff8a80;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--link); text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); line-height: 1.2; margin: 8px 0 12px; text-wrap: balance; }
h2 { font-size: 1.3rem; margin: 32px 0 12px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 760px; }
.lead { font-size: 1.08rem; color: var(--muted); max-width: 70ch; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 16px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; z-index: 10; }

.top { border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.top-row { display: flex; align-items: center; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.logo { font-weight: 700; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.logo-mark { background: var(--ink); color: var(--accent); border-radius: 7px; padding: 2px 6px; font-size: .85rem; }
:root[data-theme="dark"] .logo-mark { background: var(--accent); color: var(--accent-ink); }
.top nav { display: flex; gap: 14px; flex-wrap: wrap; margin-left: auto; }
.top nav a { color: var(--ink); text-decoration: none; font-size: .95rem; padding: 6px 0; }
.top nav a:hover { text-decoration: underline; }
.theme-btn { border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 999px; padding: 6px 12px; min-height: 36px; cursor: pointer; font: inherit; font-size: .85rem; }

.hero { padding: 40px 0 16px; }
.search { display: flex; gap: 8px; margin: 20px 0 12px; max-width: 720px; }
.search input { flex: 1; min-width: 0; font: inherit; font-size: 1.05rem; padding: 12px 14px; border: 2px solid var(--ink); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: var(--radius); padding: 10px 16px; min-height: 44px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { filter: brightness(.95); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn[disabled] { opacity: .6; cursor: wait; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font: inherit; font-size: .9rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 6px 12px; min-height: 36px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip small { color: inherit; opacity: .7; }
.search-status { color: var(--muted); min-height: 1.5em; }

.grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--gap); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; content-visibility: auto; contain-intrinsic-size: auto 180px; }
.card-title { font-weight: 700; font-size: 1.05rem; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.card-title:hover { text-decoration: underline; }
.card-meta { margin: 0; display: flex; gap: 8px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); align-items: center; }
.card-desc { margin: 0; font-size: .93rem; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.card-nums { margin: auto 0 0; display: flex; gap: 12px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.kind { font-weight: 600; border: 1px solid currentColor; border-radius: 6px; padding: 0 6px; }
.kind-mcp-server { color: var(--mcp); } .kind-agent { color: var(--agent); } .kind-skill { color: var(--skill); } .kind-tool { color: var(--tool); }
.warn { color: var(--warn); font-weight: 600; }
.lvl { font-weight: 600; } .lvl-unchecked { color: var(--lvl-u); } .lvl-scanned { color: var(--lvl-s); } .lvl-reviewed { color: var(--lvl-r); }

.cats { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.cats a { display: grid; gap: 2px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); color: var(--ink); text-decoration: none; height: 100%; }
.cats a:hover { border-color: var(--ink); }
.cats span { color: var(--muted); font-size: .9rem; } .cats small { color: var(--muted); }

.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 24px 0 40px; }
.box form, form.box { display: grid; gap: 8px; }
label { font-weight: 600; font-size: .95rem; }
input, select, textarea { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); width: 100%; }
.row { display: flex; gap: 8px; } .row input { flex: 1; min-width: 0; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-msg { margin: 4px 0 0; min-height: 1.5em; } .form-msg.ok { color: var(--lvl-r); font-weight: 600; } .form-msg.err { color: var(--warn); font-weight: 600; }

.crumbs { font-size: .9rem; color: var(--muted); margin-top: 20px; }
.tool .lead { color: var(--ink); }
.label-box { border: 1px solid var(--line); border-left: 4px solid var(--lvl-u); border-radius: var(--radius); padding: 10px 16px; background: var(--surface); margin: 16px 0; }
.label-box p { margin: 4px 0; }
.label-box.lvl-scanned { border-left-color: var(--lvl-s); } .label-box.lvl-reviewed { border-left-color: var(--lvl-r); }
.label-box.lvl-unchecked, .label-box.lvl-scanned, .label-box.lvl-reviewed { color: var(--ink); }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin: 16px 0; }
.facts div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.facts dt { font-size: .82rem; color: var(--muted); } .facts dd { margin: 2px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.links { padding-left: 20px; } .links li { margin: 6px 0; }
.share { display: flex; gap: 8px; flex-wrap: wrap; }
.levels { display: grid; gap: 12px; } .levels dt { font-weight: 700; } .levels dd { margin: 4px 0 0; }
.pager { display: flex; justify-content: space-between; align-items: center; margin: 24px 0 40px; gap: 8px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: var(--surface); }
th, td { border: 1px solid var(--line); padding: 10px 12px; text-align: left; vertical-align: top; }
thead th { background: var(--bg); }
table.admin { font-size: .9rem; } table.admin td { overflow-wrap: anywhere; }
.page-msg { padding: 48px 16px; }
.foot { border-top: 1px solid var(--line); margin-top: 48px; padding: 20px 0 32px; color: var(--muted); font-size: .9rem; }
@media (max-width: 640px) {
  .top nav { margin-left: 0; width: 100%; order: 3; gap: 12px; overflow-x: auto; flex-wrap: nowrap; }
  .top nav a { white-space: nowrap; }
  .theme-btn { margin-left: auto; }
  .row { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
.wrap.narrow > h1:first-child, .wrap.narrow > .box:first-child { margin-top: 32px; }
