:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --ink: #1b1d1f;
  --ink-2: #4a4f55;
  --ink-3: #6b7178;
  --line: #e2e2dc;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e3f3f1;
  --link: #0b6b8a;
  --warn: #9a3412;
  --warn-soft: #fff1e8;
  --focus: #d97706;
  --code-bg: #f2f2ee;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121416;
    --surface: #1a1d20;
    --surface-2: #22262a;
    --ink: #e8e9ea;
    --ink-2: #b4b9bf;
    --ink-3: #8c939a;
    --line: #2e3337;
    --accent: #2dd4bf;
    --accent-ink: #062a27;
    --accent-soft: #123532;
    --link: #67c7e6;
    --warn: #fdba74;
    --warn-soft: #3a2415;
    --focus: #fbbf24;
    --code-bg: #1f2326;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
}
a { color: var(--link); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
code, kbd, pre { font-family: var(--mono); font-size: 0.88em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -40px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { top: 8px; }
.muted { color: var(--ink-3); font-weight: 400; }
[hidden] { display: none !important; }

/* Header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-inner, .credit-line, main, .foot p { max-width: 1240px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background:
  linear-gradient(var(--accent-ink), var(--accent-ink)) 5px 6px / 12px 2.5px no-repeat,
  linear-gradient(var(--accent-ink), var(--accent-ink)) 5px 10px / 8px 2.5px no-repeat,
  linear-gradient(var(--accent-ink), var(--accent-ink)) 5px 14px / 10px 2.5px no-repeat,
  var(--accent); }
.top-nav { display: flex; gap: 4px; }
.top-nav a { color: var(--ink-2); text-decoration: none; padding: 6px 10px; border-radius: 6px; font-size: 14px; }
.top-nav a:hover { background: var(--surface-2); color: var(--ink); }
.top-nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); font-weight: 600; }
.credit-line { margin: 0 auto; padding-bottom: 10px; font-size: 13px; color: var(--ink-2); }

main { padding-top: 20px; padding-bottom: 40px; outline: none; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--ink);
  font: 600 13px/1 var(--sans); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-small { min-height: 28px; padding: 4px 9px; font-size: 12px; }

/* List layout */
.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 28px; align-items: start; }
.cats { position: sticky; top: 16px; }
.cats-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); margin: 6px 0 8px; }
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-list button {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  min-height: 32px; padding: 5px 10px; border: 0; border-radius: 6px; background: none;
  color: var(--ink-2); font: 14px/1.3 var(--sans); text-align: left; cursor: pointer;
}
.cat-list button:hover { background: var(--surface-2); color: var(--ink); }
.cat-list button[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.cat-list .n { font: 12px var(--mono); color: var(--ink-3); }

.toolbar { display: flex; gap: 10px; align-items: center; }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink-3);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: none; color: var(--ink); font: 15px var(--sans); padding: 8px 0; }
.search kbd { border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: 11px; color: var(--ink-3); }
.count { margin: 12px 0 6px; font-size: 13px; color: var(--ink-3); }

.skill-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.skill-list:empty { display: none; }
.skill-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; align-items: center; padding: 11px 14px; border-top: 1px solid var(--line); position: relative; }
.skill-row:first-child { border-top: 0; }
.skill-row:hover { background: var(--surface-2); }
.skill-row a.name { font: 600 14px var(--mono); color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.skill-row a.name::after { content: ""; position: absolute; inset: 0; }
.skill-row a.name:focus-visible { outline: none; }
.skill-row:has(a.name:focus-visible) { outline: 2px solid var(--focus); outline-offset: -2px; }
.skill-row .desc { grid-column: 1; margin: 0; color: var(--ink-2); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.skill-row .tags { grid-column: 2; grid-row: 1 / span 2; display: flex; align-items: center; gap: 8px; }
.skill-row .dl { position: relative; z-index: 1; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.tag::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--dot, var(--ink-3)); }

.state { margin-top: 12px; padding: 18px; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--surface); }
.state p { margin: 0 0 10px; }
.state-error { border-style: solid; border-color: var(--warn); background: var(--warn-soft); }

/* Skill detail */
.crumbs { font-size: 13px; color: var(--ink-3); margin-bottom: 10px; }
.skill-head h1 { font: 700 26px/1.25 var(--mono); margin: 0 0 6px; letter-spacing: -0.01em; overflow-wrap: anywhere; outline: none; }
.skill-desc { margin: 0 0 14px; color: var(--ink-2); max-width: 80ch; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.skill-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; margin-top: 22px; align-items: start; }
.side { display: grid; gap: 14px; position: sticky; top: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.panel h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); margin: 0 0 10px; }
.meta { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; margin: 0; font-size: 13.5px; }
.meta dt { color: var(--ink-3); }
.meta dd { margin: 0; overflow-wrap: anywhere; }
.meta.wide { max-width: 760px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.files { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; font: 12.5px/1.8 var(--mono); }
.files a { color: var(--ink-2); text-decoration: none; overflow-wrap: anywhere; }
.files a:hover { color: var(--link); text-decoration: underline; }

.cmd { position: relative; }
.cmd pre { margin: 0; padding: 12px 70px 12px 12px; background: var(--code-bg); border: 1px solid var(--line); border-radius: 6px; overflow-x: auto; font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.cmd .copy { position: absolute; top: 7px; right: 7px; }

.doc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 28px 24px; min-width: 0; overflow-wrap: break-word; }
.doc.loading { color: var(--ink-3); padding: 24px 28px; }
.doc:has(> .state:only-child) { padding: 0; border: 0; background: none; }
.doc > .state:only-child { margin-top: 0; }
.doc h1, .doc h2, .doc h3 { line-height: 1.3; margin: 1.4em 0 0.5em; }
.doc h1 { font-size: 22px; }
.doc h2 { font-size: 18px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.doc h3 { font-size: 15.5px; }
.doc pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 6px; padding: 12px; overflow-x: auto; line-height: 1.5; }
.doc :not(pre) > code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }
.doc table { border-collapse: collapse; display: block; overflow-x: auto; font-size: 13.5px; }
.doc th, .doc td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.doc th { background: var(--surface-2); }
.doc blockquote { margin: 1em 0; padding: 2px 14px; border-left: 3px solid var(--accent); color: var(--ink-2); }
.doc img { max-width: 100%; }
.doc .fm { margin: 16px 0 0; font-size: 12px; color: var(--ink-3); }

/* Prose pages */
.prose-view { max-width: 860px; }
.prose-view h1 { font-size: 26px; margin: 0 0 10px; outline: none; }
.prose-view h2 { font-size: 16px; margin: 26px 0 8px; }
.endpoints { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-size: 14px; }
.endpoints th, .endpoints td { padding: 9px 12px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.endpoints th { background: var(--surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); }
.endpoints td:first-child { white-space: nowrap; }
.license { background: var(--code-bg); border: 1px solid var(--line); border-radius: 6px; padding: 14px; white-space: pre-wrap; font-size: 12.5px; }

.foot { border-top: 1px solid var(--line); background: var(--surface); }
.foot p { margin: 0 auto; padding-top: 16px; padding-bottom: 16px; font-size: 13px; color: var(--ink-2); }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 6px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity 0.15s, transform 0.15s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 960px) {
  .skill-body { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; order: -1; }
}
@media (max-width: 760px) {
  .top-inner, .credit-line, main, .foot p { padding-left: 16px; padding-right: 16px; }
  .top-inner { min-height: 0; padding-top: 10px; padding-bottom: 4px; }
  .top-nav { margin-left: -10px; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .cats { position: static; }
  .cats-title { display: none; }
  .cat-list { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
  .cat-list button { width: auto; white-space: nowrap; border: 1px solid var(--line); background: var(--surface); }
  .toolbar { flex-wrap: wrap; }
  .search { flex-basis: 100%; }
  #all-zip { width: 100%; justify-content: center; }
  .skill-row { grid-template-columns: minmax(0, 1fr); }
  .skill-row .tags { grid-column: 1; grid-row: auto; justify-content: space-between; }
  .doc { padding: 4px 16px 18px; }
  .skill-head h1 { font-size: 21px; }
  .endpoints thead { display: none; }
  .endpoints tr, .endpoints td { display: block; }
  .endpoints td { border-top: 0; padding: 2px 12px; }
  .endpoints td:first-child { white-space: normal; overflow-wrap: anywhere; padding-top: 10px; border-top: 1px solid var(--line); }
  .endpoints td:last-child { padding-bottom: 10px; }
  .endpoints tr:first-child td:first-child { border-top: 0; }
  .prose-view code { overflow-wrap: anywhere; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}
