:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e2e5ea;
  --text: #1b1f24;
  --muted: #667085;
  --accent: #2f5bd3;
  --accent-ink: #ffffff;
  --accent-soft: #e8eefc;
  --danger: #c4372b;
  --danger-soft: #fdecea;
  --ok: #1d7a4a;
  --ok-soft: #e6f4ec;
  --warn: #9a6a00;
  --warn-soft: #fdf3dc;
  --code-bg: #f3f4f7;
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1e232b;
    --border: #2a3039;
    --text: #e6e9ee;
    --muted: #8d96a3;
    --accent: #6d93ff;
    --accent-ink: #0b1020;
    --accent-soft: #1d2840;
    --danger: #ff6b5e;
    --danger-soft: #3a1c1a;
    --ok: #5fd39a;
    --ok-soft: #14301f;
    --warn: #f0c060;
    --warn-soft: #33290f;
    --code-bg: #12161b;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .5rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .6rem; }
code, pre { font-family: var(--mono); font-size: .86em; }
code { background: var(--code-bg); padding: .1em .35em; border-radius: 4px; }
pre { background: var(--code-bg); padding: .8rem 1rem; border-radius: 6px; overflow-x: auto; margin: 0; white-space: pre; }
pre code { background: none; padding: 0; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 1.5rem; padding-bottom: 2rem; min-height: 70vh; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; gap: 1.5rem; height: 56px; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: .25rem; flex: 1; overflow-x: auto; }
.nav a { color: var(--muted); padding: .4rem .7rem; border-radius: 6px; white-space: nowrap; }
.nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--surface-2); font-weight: 600; }
.nav-user { display: flex; align-items: center; gap: .75rem; white-space: nowrap; }
.user-chip { color: var(--text); font-weight: 500; }

.footer { color: var(--muted); font-size: .82rem; padding: 1.5rem 16px 2rem; border-top: 1px solid var(--border); }
.footer a { color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.center { text-align: center; }
.narrow { max-width: 420px; margin: 3rem auto; }
.narrow-wide { max-width: 760px; margin: 0 auto; }
.err-code { font-size: 3rem; font-weight: 700; color: var(--muted); }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.lead { color: var(--muted); margin: .25rem 0 .5rem; font-size: 1.02rem; }
.crumbs { color: var(--muted); font-size: .85rem; margin-bottom: .5rem; }

.grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
@media (max-width: 900px) { .grid { grid-template-columns: minmax(0, 1fr); } }

.btn { display: inline-block; background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); border-radius: 6px;
  padding: .45rem .9rem; font: inherit; font-weight: 600; cursor: pointer; line-height: 1.3; }
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn-sm { padding: .25rem .6rem; font-size: .85rem; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.link-btn.danger, .danger { color: var(--danger); }
form.inline { display: inline; }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: .42rem .6rem; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=file] { padding: .35rem; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .88rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .5rem; color: var(--text); }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.row-form { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .8rem; align-items: center; }
.row-form input { flex: 1 1 140px; }
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
@media (max-width: 640px) { .row3 { grid-template-columns: 1fr; } }

.search { display: flex; gap: .5rem; flex-wrap: wrap; }
.search input[type=search] { width: 300px; max-width: 100%; }
.ns-input { width: 140px; }

.tabs { display: flex; gap: .25rem; box-shadow: inset 0 -1px 0 var(--border); margin-bottom: 1rem; overflow-x: auto; overflow-y: hidden; }
.tabs a { padding: .55rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.count { display: inline-block; min-width: 1.4em; padding: 0 .4em; border-radius: 99px; background: var(--surface-2);
  color: var(--muted); font-size: .78rem; text-align: center; font-weight: 500; }

.list { display: flex; flex-direction: column; gap: .5rem; }
.item { display: flex; justify-content: space-between; gap: 1rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .85rem 1.1rem; color: var(--text); }
.item:hover { border-color: var(--accent); text-decoration: none; }
.item-main { min-width: 0; }
.item-title { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.item-desc { color: var(--muted); font-size: .92rem; margin-top: .2rem; }
.item-side { text-align: right; flex-shrink: 0; }
.ver { font-family: var(--mono); font-weight: 600; }
.fqcn { font-weight: 600; font-size: 1.02rem; word-break: break-all; }
.fqcn-lg { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; word-break: break-all; }
.ns { color: var(--muted); font-weight: 500; }

.kind { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; padding: .12rem .45rem; border-radius: 4px; font-weight: 600; white-space: nowrap; }
.kind-collection { background: var(--accent-soft); color: var(--accent); }
.kind-role { background: var(--ok-soft); color: var(--ok); }
.kind-template { background: var(--warn-soft); color: var(--warn); }
.badge { font-size: .7rem; padding: .1rem .4rem; border-radius: 4px; background: var(--surface-2); color: var(--muted); font-weight: 600; vertical-align: middle; }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.tags { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .35rem; }
.tag { font-size: .76rem; padding: .05rem .45rem; border-radius: 99px; border: 1px solid var(--border); color: var(--muted); margin-right: .2rem; }
.grant { display: inline-block; font-size: .78rem; padding: .1rem .45rem; border-radius: 4px; margin: .1rem .25rem .1rem 0; font-weight: 600; }
.grant code { background: none; font-weight: 400; }
.grant-read { background: var(--surface-2); color: var(--text); }
.grant-publish { background: var(--accent-soft); color: var(--accent); }
.grant-admin { background: var(--danger-soft); color: var(--danger); }
.grant-none { background: var(--surface-2); color: var(--muted); }

.flash { padding: .7rem 1rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid transparent; }
.flash-ok { background: var(--ok-soft); color: var(--text); border-color: var(--ok); }
.flash-error { background: var(--danger-soft); color: var(--text); border-color: var(--danger); }
.flash .code-block { margin-top: .5rem; }

.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: .8rem; border-bottom: 1px solid var(--border); padding: .4rem .5rem; }
.table td { border-bottom: 1px solid var(--border); padding: .55rem .5rem; vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table.compact td { padding: .35rem .4rem; }
.table tr.selected td { background: var(--accent-soft); }
.table tr.dim td { opacity: .55; }
.main-col .card:has(.table) { overflow-x: auto; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: .35rem .9rem; margin: 0; font-size: .9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; word-break: break-word; }
.hash { font-size: .8rem; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: .2rem 0; }
.between { display: flex; justify-content: space-between; align-items: center; }

.code-block { position: relative; margin-bottom: .8rem; }
.code-block pre { padding-right: 4.5rem; }
.copy { position: absolute; top: .4rem; right: .4rem; font-size: .75rem; padding: .15rem .5rem; border-radius: 4px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); cursor: pointer; }
.copy:hover { color: var(--text); }

.readme { overflow-wrap: anywhere; }
.readme h1 { font-size: 1.45rem; }
.readme h1, .readme h2 { border-bottom: 1px solid var(--border); padding-bottom: .3rem; margin-top: 1.2rem; }
.readme > :first-child { margin-top: 0; }
.readme table { border-collapse: collapse; }
.readme th, .readme td { border: 1px solid var(--border); padding: .3rem .6rem; }
.readme img { max-width: 100%; }
.readme pre { margin: .6rem 0; }

details.menu { display: inline-block; position: relative; }
details.menu summary { list-style: none; }
details.menu summary::-webkit-details-marker { display: none; }
.menu-body { position: absolute; right: 0; z-index: 5; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: .75rem; box-shadow: 0 8px 24px rgba(0,0,0,.12); display: flex; flex-direction: column; gap: .5rem; width: 290px; text-align: left; }
.menu-body .row-form { margin-top: 0; }

.danger-zone { border-color: var(--danger-soft); display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.danger-zone h3 { width: 100%; }
.empty { text-align: center; color: var(--muted); padding: 2.5rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }

@media (max-width: 640px) {
  .topbar-inner { gap: .75rem; }
  .brand span { display: none; }
  .item { flex-direction: column; }
  .item-side { text-align: left; display: flex; gap: .75rem; align-items: baseline; }
}
