/* Selected direction — Linear-inspired command catalog */
body[data-theme^="command"] {
  color-scheme: dark;
  --ground: #08090a;
  --surface: #16171c;
  --surface-raised: #1e1f25;
  --ink: #f7f8f8;
  --muted: #9ca3af;
  --faint: rgba(255, 255, 255, 0.08);
  --accent: #5e6ad2;
  --secondary: #a9b0c2;
  --button-ink: #f7f8f8;
  --radius: 6px;
  --radius-large: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --font-display: "Aptos Display", "SF Pro Display", "PingFang SC", sans-serif;
  --font-body: "Aptos", "SF Pro Text", "PingFang SC", sans-serif;
  --page-width: 1220px;
  --card-gap: 8px;
  --card-padding: 18px 18px;
  --motion-fast: 150ms;
  --motion-layout: 380ms;
}

body[data-theme^="command"]::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: 440px;
  pointer-events: none;
  background:
    radial-gradient(circle at 72% -12%, rgba(94, 106, 210, 0.075), transparent 48%),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.018), transparent 70%);
}

body[data-theme^="command"] .site-header {
  position: relative;
  min-height: 64px;
  border-color: var(--faint);
}

body[data-theme^="command"] .wordmark {
  font-weight: 620;
  letter-spacing: -0.01em;
}

body[data-theme^="command"] .wordmark-mark {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.1);
}

body[data-theme^="command"] .page-shell {
  position: relative;
  padding-top: 74px;
}

body[data-theme^="command"] .search-intro {
  grid-template-columns: 1fr;
  max-width: 920px;
  gap: 24px;
  margin: 0 auto;
  padding-bottom: 62px;
  border: 0;
  text-align: center;
}

body[data-theme^="command"] .intro-copy h1 {
  font-size: clamp(43px, 5.4vw, 72px);
  font-weight: 630;
  letter-spacing: -0.055em;
  line-height: 0.98;
}

body[data-theme^="command"] .intro-copy p {
  margin: 19px auto 0;
  max-width: 580px;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.7;
}

body[data-theme^="command"] .search-form {
  min-height: 64px;
  margin-top: 8px;
  padding: 0 10px 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 12px;
  background: rgba(22, 23, 28, 0.9);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.28);
  text-align: left;
}

body[data-theme^="command"] .search-form input {
  padding: 15px 0;
  font-size: 16px;
}

body[data-theme^="command"] .search-form button {
  border-radius: 7px;
  background: var(--accent);
}

body[data-theme^="command"] .catalog-layout {
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  padding-top: 0;
}

body[data-theme^="command"] .filters-panel,
body[data-theme^="command"] .results-region {
  border: 1px solid var(--faint);
  border-radius: 12px;
  background: rgba(22, 23, 28, 0.78);
  box-shadow: var(--shadow);
}

body[data-theme^="command"] .filters-panel {
  top: 16px;
  padding: 16px;
}

body[data-theme^="command"] .filter-heading {
  min-height: 36px;
}

body[data-theme^="command"] .filter-field select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--faint);
  background: var(--surface-raised);
}

body[data-theme^="command"] .tag-option {
  min-height: 28px;
  background: var(--surface-raised);
}

body[data-theme^="command"] .data-note {
  font-family: var(--font-body);
  font-size: 10px;
}

body[data-theme^="command"] .results-region {
  padding: 18px;
}

body[data-theme^="command"] .results-toolbar {
  min-height: 70px;
  padding: 0 2px 16px;
}

body[data-theme^="command"] .results-toolbar h2 {
  font-size: 21px;
  font-weight: 620;
  letter-spacing: -0.025em;
}

body[data-theme^="command"] .results-list {
  border-top-color: var(--faint);
}

body[data-theme^="command"] .problem-card {
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 18px;
  border: 1px solid var(--faint);
}

body[data-theme^="command"] .problem-card:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background: #1a1b21;
  transform: translateY(-1px);
}

body[data-theme^="command"] .problem-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

body[data-theme^="command"] .problem-summary {
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 1.6;
}

body[data-theme^="command"] .difficulty-label,
body[data-theme^="command"] .tag-chip {
  min-height: 30px;
  padding-inline: 9px;
  background: var(--surface-raised);
  font-family: var(--font-mono);
  font-size: 9px;
}

body[data-theme^="command"] .problem-link {
  min-height: 30px;
  min-width: 78px;
  border-color: var(--faint);
  background: var(--surface-raised);
}

body[data-theme^="command"] .problem-link:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: var(--surface-raised);
  color: var(--ink);
}

body[data-theme^="command"] .problem-link.hydro-link {
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
}

body[data-theme^="command"] .problem-link.hydro-link:hover {
  background: var(--accent);
  color: var(--ink);
}

body[data-theme^="command"] .loading-row {
  padding-inline: 18px;
  border-color: var(--faint);
}

@media (max-width: 1050px) {
  .search-intro {
    grid-template-columns: 1fr 1fr;
  }

  .search-intro > .eyebrow {
    grid-column: 1 / -1;
  }

  .catalog-layout,
  body[data-theme^="command"] .catalog-layout {
    grid-template-columns: 1fr;
  }

  .filters-panel,
  body[data-theme^="command"] .filters-panel {
    position: static;
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 14px;
    align-items: end;
  }

  .filter-heading,
  .filter-field {
    margin-bottom: 0;
  }

  .tag-filter,
  .data-note {
    grid-column: 1 / -1;
  }

  .problem-card,
  body[data-theme^="command"] .problem-card {
    grid-template-columns: 120px minmax(0, 1fr);
  }

}

@media (max-width: 720px) {
  .site-header,
  .page-shell {
    width: min(calc(100% - 28px), var(--page-width));
  }

  .site-header {
    min-height: 62px;
  }

  .header-meta span:first-child,
  .header-rule {
    display: none;
  }

  .page-shell,
  body[data-theme^="command"] .page-shell {
    padding-top: 48px;
  }

  .search-intro,
  body[data-theme^="command"] .search-intro {
    grid-template-columns: 1fr;
    gap: 24px;
    padding-bottom: 48px;
    text-align: left;
  }

  body[data-theme^="command"] .intro-copy p {
    margin-inline: 0;
  }

  .intro-copy h1,
  body[data-theme^="command"] .intro-copy h1 {
    font-size: clamp(42px, 14vw, 62px);
  }

  .search-form,
  body[data-theme^="command"] .search-form {
    grid-template-columns: 1fr auto;
    padding-left: 0;
  }

  body[data-theme^="command"] .search-form {
    padding-left: 14px;
  }

  .search-form kbd {
    display: none;
  }

  .catalog-layout {
    gap: 52px;
    padding-top: 48px;
  }

  .filters-panel,
  body[data-theme^="command"] .filters-panel {
    grid-template-columns: 1fr 1fr;
  }

  .filter-heading,
  .tag-filter,
  .data-note {
    grid-column: 1 / -1;
  }

  .results-toolbar {
    min-height: 88px;
  }

  .active-filter-summary {
    max-width: 52%;
  }

  .problem-card,
  body[data-theme^="command"] .problem-card {
    grid-template-columns: 1fr;
    gap: 15px;
    padding: 24px 0;
  }

  body[data-theme^="command"] .problem-card {
    padding: 16px;
  }

  .problem-identity {
    flex-direction: row;
    gap: 9px;
  }

  .problem-link {
    min-height: 44px;
  }

  .loading-row {
    grid-template-columns: 1fr;
  }

  .pagination {
    justify-content: center;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Selected direction — command catalog, refined filters */
body[data-theme^="command"] .page-shell {
  padding-top: 42px;
}

body[data-theme^="command"] .search-intro {
  max-width: none;
  margin: 0;
  padding-bottom: 28px;
}

body[data-theme^="command"] .search-form {
  width: 100%;
  margin-top: 0;
}

body[data-theme^="command"] .catalog-layout {
  grid-template-columns: 256px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

body[data-theme^="command"] .filters-panel {
  position: sticky;
  top: 16px;
  display: block;
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

body[data-theme^="command"] .filter-heading {
  min-height: 70px;
  margin: 0;
  padding: 15px 16px;
  border-bottom: 1px solid var(--faint);
}

.filter-heading > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.filter-heading strong {
  font-size: 14px;
  font-weight: 620;
  letter-spacing: -0.01em;
}

.filter-kicker {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.filter-heading-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

body[data-theme^="command"] .filter-heading .text-button {
  min-height: 30px;
  padding: 4px 0;
  color: var(--muted);
  font-size: 10px;
}

body[data-theme^="command"] .filter-heading .text-button:not(:disabled):hover {
  color: var(--ink);
}

.filter-close {
  display: none;
  min-height: 32px;
  padding: 4px 9px;
  border: 1px solid var(--faint);
  border-radius: 6px;
  background: var(--surface-raised);
  cursor: pointer;
  font-size: 11px;
}

.filter-group {
  padding: 16px;
  border-bottom: 1px solid var(--faint);
}

.filter-group:last-child {
  border-bottom: 0;
}

.filter-group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.filter-group-heading > span {
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
}

.filter-group-heading small {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.05em;
}

.filter-options,
body[data-theme^="command"] .tag-options {
  display: grid;
  gap: 4px;
}

.difficulty-options {
  gap: 10px;
}

.difficulty-all-option {
  margin-bottom: 2px;
}

.difficulty-section {
  display: grid;
  gap: 4px;
}

.difficulty-section-label {
  margin: 0;
  padding: 0 2px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.5;
  text-transform: uppercase;
}

.difficulty-section-options {
  display: grid;
  gap: 4px;
}

.difficulty-section-options[data-kind="course"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.difficulty-section-options[data-kind="rating"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.difficulty-section-options[data-kind="course"] .filter-option,
.difficulty-section-options[data-kind="rating"] .filter-option {
  gap: 5px;
  padding-inline: 7px;
}

.difficulty-section-options[data-kind="course"] .filter-option-count,
.difficulty-section-options[data-kind="rating"] .filter-option-count {
  min-width: 21px;
  padding-inline: 3px;
}

.filter-option {
  width: 100%;
  min-height: 36px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: background 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out;
}

.filter-option:hover {
  border-color: var(--faint);
  background: rgba(255, 255, 255, 0.025);
  color: var(--ink);
}

.filter-option[aria-pressed="true"] {
  border-color: rgba(94, 106, 210, 0.46);
  background: rgba(94, 106, 210, 0.12);
  color: var(--ink);
}

.filter-option-label {
  min-width: 0;
  overflow: hidden;
  font-size: 11px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-option-count {
  min-width: 24px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  padding: 0 5px;
  border: 1px solid var(--faint);
  border-radius: 5px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
}

.filter-option[aria-pressed="true"] .filter-option-count {
  border-color: rgba(94, 106, 210, 0.5);
  color: #aeb3ff;
}

body[data-theme^="command"] .tag-options {
  grid-template-columns: 1fr 1fr;
}

body[data-theme^="command"] .tag-options .filter-option {
  min-width: 0;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -4px 0 15px;
  padding: 0 2px 14px;
  border-bottom: 1px solid var(--faint);
}

.active-filter {
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid rgba(94, 106, 210, 0.4);
  border-radius: 6px;
  background: rgba(94, 106, 210, 0.1);
  color: #c5c8ff;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 9px;
  transition: border-color 150ms ease-out, background 150ms ease-out;
}

.active-filter:hover {
  border-color: rgba(94, 106, 210, 0.72);
  background: rgba(94, 106, 210, 0.18);
}

.filter-mobile-toggle {
  display: none;
}

.filter-backdrop {
  display: none;
}

@media (max-width: 850px) {
  body[data-theme^="command"] .catalog-layout {
    display: block;
  }

  .filter-mobile-toggle {
    width: 100%;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 9px 12px;
    border: 1px solid var(--faint);
    border-radius: 9px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    font-size: 12px;
  }

  .filter-mobile-toggle span:last-child {
    min-width: 25px;
    height: 22px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--faint);
    border-radius: 5px;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 9px;
  }

  .filter-mobile-toggle.has-filters span:last-child {
    border-color: rgba(94, 106, 210, 0.56);
    background: rgba(94, 106, 210, 0.16);
    color: #c5c8ff;
  }

  .filter-backdrop {
    position: fixed;
    inset: 0;
    z-index: 109;
    display: block;
    border: 0;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(3px);
  }

  body[data-theme^="command"] .filters-panel {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 110;
    width: min(360px, calc(100vw - 32px));
    max-height: none;
    display: block;
    overflow-y: auto;
    border-width: 0 1px 0 0;
    border-radius: 0 14px 14px 0;
    background: #121318;
    box-shadow: 28px 0 90px rgba(0, 0, 0, 0.44);
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform 360ms cubic-bezier(0.22, 1, 0.36, 1), visibility 360ms;
  }

  body[data-theme^="command"] .filters-panel.is-open {
    transform: translateX(0);
    visibility: visible;
  }

  body[data-theme^="command"] .filter-heading {
    position: sticky;
    top: 0;
    z-index: 2;
    background: rgba(18, 19, 24, 0.96);
    backdrop-filter: blur(14px);
  }

  .filter-close {
    display: inline-flex;
    align-items: center;
  }

  body[data-theme^="command"] .results-region {
    padding: 14px;
  }
}

@media (max-width: 560px) {
  body[data-theme^="command"] .page-shell {
    padding-top: 26px;
  }

  body[data-theme^="command"] .search-intro {
    padding-bottom: 18px;
  }

  body[data-theme^="command"] .search-form {
    min-height: 58px;
  }

  body[data-theme^="command"] .tag-options {
    grid-template-columns: 1fr;
  }

  .problem-info-row {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 10px;
  }

  .problem-actions {
    justify-content: flex-start;
  }

  .active-filters {
    margin-top: 0;
  }
}
