:root {
  color-scheme: dark;
  --bg: #0b0b0b;
  --surface: #151515;
  --surface-hover: #1b1b1b;
  --text: #f4f4f4;
  --muted: #9a9a9a;
  --border: #292929;
  --border-strong: #3a3a3a;
  --focus: #d5d5d5;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  padding: 32px 18px 22px;
  background:
    radial-gradient(circle at 50% -20%, #1a1a1a 0, transparent 42%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", sans-serif;
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button,
select,
summary {
  cursor: pointer;
}

a {
  color: inherit;
}

main {
  width: min(980px, 100%);
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.back-link:hover {
  border-color: var(--border-strong);
  background: #202020;
}

.back-link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(1.75rem, 4vw, 2.4rem);
  font-weight: 600;
  letter-spacing: -0.035em;
}

.intro {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.intro code,
.usage,
.subcommand-row code {
  font-family: Consolas, "Courier New", monospace;
}

.intro code {
  color: var(--text);
}

.command-total {
  color: var(--muted);
  font-size: 0.92rem;
  white-space: nowrap;
}

.command-total strong {
  color: var(--text);
  font-weight: 600;
}

.command-tools {
  position: sticky;
  z-index: 10;
  top: 0;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 200px 180px auto;
  gap: 10px;
  margin: 18px 0 28px;
  padding: 10px 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
}

.search-field,
.select-field {
  position: relative;
  display: block;
}

.search-field > span,
.select-field > span {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.search-field input,
.select-field select,
.clear-filters {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.search-field input {
  padding: 0 48px 0 13px;
}

.select-field select {
  padding: 0 36px 0 12px;
}

.search-field input::placeholder {
  color: #737373;
}

.search-field input:focus,
.select-field select:focus,
.clear-filters:focus-visible,
.empty-state button:focus-visible,
.command-card summary:focus-visible {
  border-color: var(--focus);
  outline: 2px solid transparent;
}

.search-field kbd {
  position: absolute;
  top: 11px;
  right: 11px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  color: var(--muted);
  font: 0.75rem Consolas, monospace;
}

.clear-filters {
  width: auto;
  padding: 0 14px;
  color: var(--muted);
}

.clear-filters:hover,
.empty-state button:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  color: var(--text);
}

.category {
  min-width: 0;
  margin-bottom: 34px;
}

.quick-guides {
  margin-top: 22px;
}

.quick-guides h2 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.quick-guides details {
  margin-top: 8px;
  scroll-margin-top: 180px;
}

.quick-guides details:first-of-type {
  margin-top: 14px;
}

.quick-guides summary {
  min-height: 45px;
}

.quick-guides li {
  margin-bottom: 8px;
}

.example {
  display: flex;
  align-items: start;
  gap: 6px;
  min-width: 0;
}

.example .usage {
  min-width: 0;
}

.example button {
  padding: 5px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
}

.copy-status:not(:empty) {
  position: fixed;
  z-index: 11;
  bottom: 14px;
  right: 14px;
  max-width: calc(100% - 28px);
  padding: 9px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
}

.category[hidden],
.command-card[hidden] {
  display: none;
}

.category-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 11px;
}

.category-heading h2 {
  margin-bottom: 4px;
  font-size: 1rem;
  font-weight: 600;
}

.category-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.87rem;
}

.category-count {
  min-width: 25px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.command-list {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.command-card {
  min-width: 0;
  overflow: clip;
  scroll-margin-top: 76px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.command-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.command-card[open] {
  border-color: var(--border-strong);
  background: var(--surface);
}

.command-card summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 68px;
  padding: 13px 15px;
  list-style: none;
}

.command-card summary::-webkit-details-marker {
  display: none;
}

.command-main {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.command-name {
  font: 600 0.96rem Consolas, "Courier New", monospace;
  letter-spacing: -0.02em;
}

.command-description {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-badges {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

.badge {
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.2;
}

.user-install {
  color: #d2d2d2;
}

.chevron {
  width: 8px;
  height: 8px;
  margin: 0 3px 3px 5px;
  border-right: 1px solid var(--muted);
  border-bottom: 1px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.18s ease, margin 0.18s ease;
}

.command-card[open] .chevron {
  margin-top: 5px;
  margin-bottom: 0;
  transform: rotate(225deg);
}

.command-detail {
  padding: 16px;
  border-top: 1px solid var(--border);
  animation: reveal 0.16s ease-out;
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

.detail-grid {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1.3fr) minmax(220px, 0.7fr);
  gap: 24px;
}

.detail-grid > * {
  min-width: 0;
}

.detail-block h3,
.subcommands h3 {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.usage {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 6px;
  padding: 6px 8px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #101010;
  color: #dddddd;
  font-size: 0.8rem;
  white-space: nowrap;
}

.access-list {
  display: grid;
  gap: 7px;
  margin: 0;
}

.access-list div {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 8px;
  font-size: 0.82rem;
}

.access-list dt {
  color: var(--muted);
}

.access-list dd {
  margin: 0;
}

.aliases,
.command-note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.83rem;
}

.aliases strong {
  margin-right: 7px;
  color: var(--text);
  font-weight: 500;
}

.command-note {
  padding-left: 10px;
  border-left: 2px solid var(--border-strong);
}

.subcommands {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.subcommand-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--border);
}

.subcommand-row {
  display: grid;
  gap: 4px;
  padding: 10px 11px;
  background: #111111;
}

.subcommand-row code {
  overflow-wrap: anywhere;
  color: #dedede;
  font-size: 0.79rem;
}

.subcommand-row span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.empty-state {
  padding: 80px 20px;
  border: 1px dashed var(--border);
  border-radius: 7px;
  text-align: center;
}

.empty-state h2 {
  margin-bottom: 7px;
  font-size: 1.1rem;
}

.empty-state p {
  margin-bottom: 16px;
  color: var(--muted);
}

.empty-state button {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

footer {
  display: flex;
  justify-content: center;
  gap: 7px;
  width: min(980px, 100%);
  margin: 48px auto 0;
  color: var(--muted);
  font-size: 0.82rem;
}

footer a:hover {
  color: var(--text);
}

@media (max-width: 760px) {
  body {
    padding-top: 22px;
  }

  .command-tools {
    grid-template-columns: 1fr 1fr;
  }

  .search-field {
    grid-column: 1 / -1;
  }

  .clear-filters {
    grid-column: 1 / -1;
  }

  .detail-grid,
  .subcommand-list {
    grid-template-columns: 1fr;
  }

  .usage {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .command-tools {
    grid-template-columns: 1fr;
  }

  .search-field,
  .clear-filters {
    grid-column: auto;
  }

  .command-card summary {
    align-items: flex-start;
    min-height: 0;
  }

  .command-description {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    white-space: normal;
  }

  .badge.user-install {
    display: none;
  }

  .command-detail {
    padding: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
