/* ==========================================================================
   WinAPI Atlas — design tokens
   ========================================================================== */

:root {
  --bg: #0b0f14;
  --bg-grad: radial-gradient(1200px 600px at 15% -10%, rgba(56, 189, 248, 0.09), transparent 60%),
    radial-gradient(900px 500px at 95% 0%, rgba(168, 85, 247, 0.07), transparent 55%);
  --panel: #111823;
  --panel-2: #16202c;
  --panel-3: #1b2836;
  --border: #22303f;
  --border-strong: #3a4d63;
  --text: #e6edf3;
  --text-dim: #a7b6c7;
  --text-faint: #8496aa;
  --accent: #38bdf8;
  --accent-strong: #7dd3fc;
  --accent-ink: #04121c;
  --danger: #f87171;
  --warn: #fbbf24;
  --ok: #4ade80;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
  --radius: 10px;
  --radius-sm: 7px;
  --row-h: 84px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

[data-theme="light"] {
  --bg: #f4f7fb;
  --bg-grad: radial-gradient(1100px 520px at 10% -10%, rgba(2, 132, 199, 0.1), transparent 60%),
    radial-gradient(900px 480px at 100% 0%, rgba(126, 34, 206, 0.08), transparent 55%);
  --panel: #ffffff;
  --panel-2: #f2f6fb;
  --panel-3: #e7eef7;
  --border: #d5e0ec;
  --border-strong: #a9bbcf;
  --text: #0c1723;
  --text-dim: #40546a;
  --text-faint: #5b7089;
  --accent: #0369a1;
  --accent-strong: #075985;
  --accent-ink: #ffffff;
  --danger: #b91c1c;
  --warn: #92400e;
  --ok: #15803d;
  --shadow: 0 18px 40px rgba(15, 32, 51, 0.16);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--accent);
}

code,
kbd {
  font-family: var(--mono);
  font-size: 0.92em;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0.08em 0.4em;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--text-dim);
  text-align: center;
  font-size: 11px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection {
  background: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--text);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -60px;
  left: 12px;
  z-index: 200;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 10px;
}

.muted {
  color: var(--text-dim);
}

/* Scrollbars */
* {
  scrollbar-color: var(--border-strong) transparent;
  scrollbar-width: thin;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* ==========================================================================
   Header
   ========================================================================== */

.app-header {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 9px;
  background: linear-gradient(150deg, var(--accent), #6366f1);
  color: #04121c;
  font-weight: 800;
  font-size: 17px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent), 0 6px 18px rgba(56, 189, 248, 0.25);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}

.brand-name {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-tag {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

#search {
  width: 100%;
  padding: 10px 42px 10px 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
}

#search::placeholder {
  color: var(--text-faint);
}

#search:hover {
  border-color: var(--border-strong);
}

#search:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.search-kbd {
  position: absolute;
  right: 10px;
  pointer-events: none;
  color: var(--text-faint);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-actions > .btn,
.header-actions > .export-menu > summary {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  border-radius: 8px;
}

.btn,
.export-menu > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  list-style: none;
}

.btn:hover,
.export-menu > summary:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--panel-2);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--accent-ink);
}

.toggle[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 20%, var(--panel));
  border-color: var(--accent);
  color: var(--text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

.icon-btn {
  min-width: 36px;
  justify-content: center;
}

.header-actions > .icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
}

.theme-toggle {
  color: var(--accent);
}

.theme-icon {
  display: block;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.export-menu {
  position: relative;
}

.export-menu > summary::-webkit-details-marker {
  display: none;
}

.export-menu > summary::after {
  content: "▾";
  font-size: 10px;
  color: var(--text-faint);
}

.export-pop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  width: 220px;
  padding: 8px;
  display: grid;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.export-btn {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}

.export-btn:hover {
  background: var(--panel-2);
  border-color: var(--border);
  color: var(--text);
}

.export-note {
  margin: 4px 2px 2px;
  font-size: 11px;
  color: var(--text-faint);
}

/* ==========================================================================
   Filter bar
   ========================================================================== */

.filterbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 18px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 55%, transparent);
  position: relative;
  z-index: 15;
}

.filters {
  position: relative;
}

.filters-summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

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

.filters-summary::after {
  content: "▾";
  font-size: 10px;
  color: var(--text-faint);
}

.filters[open] .filters-summary {
  border-color: var(--accent);
  color: var(--text);
}

.filters-summary:hover {
  border-color: var(--border-strong);
}

.count-pill {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--panel-3);
  color: var(--text-dim);
  font-size: 10.5px;
  font-weight: 700;
}

.filters[data-active="true"] .count-pill {
  background: var(--accent);
  color: var(--accent-ink);
}

.filter-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 70;
  width: min(860px, calc(100vw - 36px));
  max-height: min(70vh, 620px);
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.filter-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.filter-group legend,
.field-label {
  display: block;
  margin-bottom: 8px;
  padding: 0;
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.filter-verification {
  grid-column: 1 / -1;
}

.filter-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px 12px;
}

.filter-field {
  display: block;
  min-width: 0;
}

.filter-sublabel {
  display: block;
  margin-bottom: 5px;
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 600;
}

.checkgrid {
  display: grid;
  gap: 5px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}

.checkgrid-lib {
  grid-template-columns: 1fr;
}

.checkrow {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.check {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 0;
  color: var(--text-dim);
  font-size: 12.5px;
  cursor: pointer;
}

.check:hover {
  color: var(--text);
}

.check input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  margin: 0;
}

.check-count {
  margin-left: auto;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 10.5px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 11px;
  white-space: nowrap;
}

.chip[data-cat]::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cat, var(--text-faint));
}

.chip-btn {
  cursor: pointer;
}

.chip-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.chip[aria-pressed="true"] {
  border-color: var(--cat, var(--accent));
  background: color-mix(in srgb, var(--cat, var(--accent)) 18%, var(--panel));
  color: var(--text);
}

.filter-select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--font);
  font-size: 12.5px;
}

.filter-actions {
  display: flex;
  align-items: flex-end;
}

.status {
  margin: 0;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   Category tabs (mobile only)
   ========================================================================== */

.cat-tabs {
  display: none;
}

.cat-tabs[hidden] {
  display: none !important;
}

.cat-tab {
  flex: 0 0 auto;
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text-dim);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.cat-tab[aria-selected="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, var(--panel));
  color: var(--text);
}

/* ==========================================================================
   Catalog columns
   ========================================================================== */

.catalog {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.columns {
  display: flex;
  gap: 12px;
  height: 100%;
  padding: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  align-items: stretch;
  scroll-snap-type: x proximity;
}

.loading,
.error-panel {
  margin: 24px;
  color: var(--text-dim);
}

.board-empty {
  flex: 1 1 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 280px;
  padding: 36px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 62%, transparent);
  text-align: center;
}

.board-empty[hidden] {
  display: none !important;
}

.board-empty-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 3px;
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--border));
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 10%, var(--panel));
  color: var(--accent);
  font-family: var(--mono);
  font-size: 20px;
}

.board-empty h2 {
  margin: 0;
  font-size: 16px;
  color: var(--text);
}

.board-empty p {
  margin: 0;
  color: var(--text-faint);
  font-size: 12.5px;
}

.error-panel {
  max-width: 560px;
  padding: 18px 20px;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--danger) 8%, var(--panel));
}

.error-panel h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.catcol {
  flex: 0 0 276px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  scroll-snap-align: start;
}

.catcol[hidden] {
  display: none !important;
}

.catcol::before {
  content: "";
  display: block;
  height: 2px;
  flex: 0 0 2px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(90deg, var(--cat), transparent 85%);
}

.catcol-head {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 10px 12px 9px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  border-radius: 0;
}

.catcol-titles {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cat-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 2px;
  background: var(--cat);
  box-shadow: 0 0 10px color-mix(in srgb, var(--cat) 60%, transparent);
}

.catcol-title {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-title-link {
  color: inherit;
  text-decoration: none;
}

.cat-title-link::after {
  content: ' ↗';
  color: var(--text-faint);
  font-size: 9px;
}

.cat-title-link:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cat-page-link {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  text-transform: uppercase;
}

.cat-page-link:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.catcol-count {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--panel-3);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 10px;
}

.info-btn {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  margin-left: 2px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 700;
  cursor: help;
}

.info-btn:hover,
.info-btn:focus-visible {
  color: var(--text);
  border-color: var(--cat, var(--accent));
}

.cat-tip {
  position: absolute;
  top: calc(100% - 2px);
  left: 8px;
  right: 8px;
  z-index: 30;
  margin: 0;
  padding: 10px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text-dim);
  font-size: 11.5px;
  line-height: 1.5;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.catcol-head:focus-within .cat-tip,
.catcol-head:hover .cat-tip {
  opacity: 1;
  visibility: visible;
}

.catcol-sub {
  margin: 5px 0 0;
  color: var(--text-faint);
  font-size: 10.5px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.catcol-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  overscroll-behavior: contain;
}

.list-inner {
  position: relative;
  width: 100%;
}

.row-wrap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 4px 8px;
}

.apirow {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  height: calc(var(--row-h) - 8px);
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 100ms ease, background 100ms ease;
}

.apirow:hover {
  border-color: var(--border-strong);
  background: var(--panel-3);
}

.row-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-right: 14px;
}

.row-name {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-review {
  flex: 0 0 auto;
  padding: 1px 3px;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.25;
  text-transform: uppercase;
}

.row-review[data-state="reviewed"] {
  border-color: color-mix(in srgb, var(--ok) 45%, var(--border));
  color: var(--ok);
}

.row-lib {
  margin-left: auto;
  flex: 0 0 auto;
  color: var(--text-faint);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.row-desc {
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.row-susp {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
}

.row-susp[data-level="low"] {
  background: var(--ok);
}

.row-susp[data-level="medium"] {
  background: var(--warn);
}

.row-susp[data-level="high"] {
  background: var(--danger);
}

.apirow.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--panel-2));
  box-shadow: inset 2px 0 0 var(--accent);
}

.apirow.selected .row-name::after {
  content: "✓";
  margin-left: 6px;
  color: var(--accent);
  font-size: 11px;
}

mark {
  padding: 0 1px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--warn) 40%, transparent);
  color: inherit;
}

body[data-mapping="true"] .apirow {
  cursor: crosshair;
}

/* ==========================================================================
   Selection panel
   ========================================================================== */

.selpanel {
  position: fixed;
  right: 16px;
  /* Sit above the footer instead of covering its links. */
  bottom: 64px;
  z-index: 45;
  width: 360px;
  max-width: calc(100vw - 32px);
  max-height: min(72vh, 640px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.selpanel[hidden] {
  display: none;
}

.sel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.sel-title {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.sel-count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}

.sel-clear {
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 10.5px;
  cursor: pointer;
}

.sel-clear:hover {
  color: var(--text);
  border-color: var(--border);
}

.sel-clear[hidden] {
  display: none;
}

.sel-toggle {
  margin-left: auto;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text-dim);
  font: inherit;
  font-size: 10.5px;
  cursor: pointer;
}

.sel-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.sel-body {
  overflow-y: auto;
  padding: 10px 12px 12px;
}

.selpanel[data-collapsed="true"] .sel-body {
  display: none;
}

.sel-scope {
  margin: 0 0 8px;
  color: var(--text-faint);
  font-size: 11px;
}

.sel-subtitle {
  margin: 12px 0 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.sel-list,
.breakdown,
.techniques {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sel-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.sel-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-2);
  overflow: hidden;
}

.sel-chip-open {
  padding: 3px 4px 3px 9px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: 10.5px;
  cursor: pointer;
}

.sel-chip-open:hover {
  color: var(--accent);
}

.chip-x {
  padding: 3px 8px 3px 4px;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.chip-x:hover {
  color: var(--danger);
}

.sel-empty {
  color: var(--text-faint);
  font-size: 11px;
  padding: 4px 0;
}

.breakdown {
  display: grid;
  gap: 3px;
}

.breakdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-dim);
}

.breakdown-count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text);
  background: var(--panel-3);
  border-radius: 4px;
  padding: 0 5px;
}

.techniques {
  display: grid;
  gap: 9px;
}

.tech {
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
}

.tech-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.tech-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
}

.tech-score {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
}

.score-bar {
  height: 4px;
  margin: 6px 0 6px;
  border-radius: 999px;
  background: var(--panel-3);
  overflow: hidden;
}

.score-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
}

.tech-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  font-size: 10px;
}

.tech-mitre {
  flex: 1 1 62%;
  color: var(--text-dim);
  text-decoration: none;
  border-bottom: 1px dotted var(--border-strong);
}

.tech-mitre:hover {
  color: var(--accent);
}

.tech-complete {
  margin-left: auto;
  white-space: nowrap;
  color: var(--text-faint);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tech-complete[data-status="complete"] {
  color: var(--ok);
}

.tech-complete[data-status="out-of-order"] {
  color: var(--warn);
}

.tech-complete[data-status="possible"] {
  color: var(--text-dim);
}

.tech-complete[data-status="indicator"] {
  color: var(--accent);
}

.tech-why {
  margin: 5px 0 0;
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1.45;
}

.tech-missing {
  margin: 5px 0 0;
  color: var(--warn);
  font-size: 10px;
}

.tech-details {
  margin-top: 5px;
}

.tech-details summary {
  color: var(--text-faint);
  font-size: 10px;
  cursor: pointer;
}

.tech-details summary:hover {
  color: var(--text-dim);
}

.tech-note {
  margin: 5px 0 0;
  color: var(--text-dim);
  font-size: 10.5px;
  line-height: 1.45;
}

.export-block .export-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.export-block .export-btn {
  width: auto;
  flex: 1 1 auto;
  padding: 6px 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text-dim);
  text-align: center;
  font-size: 10.5px;
}

.export-block .export-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

/* ==========================================================================
   Dialogs
   ========================================================================== */

.dialog {
  width: min(760px, 92vw);
  max-height: 88vh;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(3, 7, 12, 0.66);
  backdrop-filter: blur(3px);
}

.dialog-wide {
  width: min(920px, 94vw);
}

.dialog-shell {
  display: flex;
  flex-direction: column;
  max-height: 88vh;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.dialog-title {
  margin: 0;
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 700;
  word-break: break-word;
}

.dialog-close {
  margin-left: auto;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.dialog-close:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.dialog-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}

.meta-item {
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 10.5px;
}

.text-green {
  color: #4ade80 !important; 
  font-weight: 500;
}

.text-red {
  color: #f87171 !important;
  font-weight: 500;
}

.badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge-susp[data-level="low"] {
  background: color-mix(in srgb, var(--ok) 22%, transparent);
  color: var(--ok);
  border: 1px solid color-mix(in srgb, var(--ok) 45%, transparent);
}

.badge-susp[data-level="medium"] {
  background: color-mix(in srgb, var(--warn) 22%, transparent);
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
}

.badge-susp[data-level="high"] {
  background: color-mix(in srgb, var(--danger) 22%, transparent);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
}

.badge-docs[data-value="direct"],
.badge-telemetry[data-value="direct"],
.badge-review[data-value="reviewed"] {
  background: color-mix(in srgb, var(--ok) 22%, transparent);
  color: var(--ok);
  border: 1px solid color-mix(in srgb, var(--ok) 45%, transparent);
}

.badge-telemetry[data-value="indirect"] {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 42%, transparent);
}

.badge-docs[data-value="related"],
.badge-telemetry[data-value="unknown"] {
  background: color-mix(in srgb, var(--warn) 20%, transparent);
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 42%, transparent);
}

.badge-docs[data-value="none"],
.badge-telemetry[data-value="none"],
.badge-review[data-value="unreviewed"] {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text-faint);
}

.dialog-body {
  overflow-y: auto;
  padding: 4px 20px 18px;
}

.dialog-desc {
  margin: 14px 0 6px;
  font-size: 14px;
  color: var(--text);
}

.dialog-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.dialog-section h3 {
  margin: 0 0 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.dialog-section p {
  margin: 4px 0;
  color: var(--text-dim);
  font-size: 12.5px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.link-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--text-dim);
  font-size: 12.5px;
}

.link-list li {
  margin: 3px 0;
}

.dialog-docs {
  margin-top: 16px;
}

.text-link {
  font-size: 12px;
  font-weight: 600;
}

.dialog-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
}

.dialog-foot .btn {
  font-size: 11.5px;
  padding: 7px 10px;
}

.copy-status {
  margin: 0;
  flex: 1 1 150px;
  color: var(--text-faint);
  font-size: 10.5px;
}

/* Contribute form */

.contribute-form {
  margin-top: 14px;
}

.mode-switch {
  display: flex;
  gap: 4px;
  margin: 0 0 12px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel-2);
}

.mode-btn {
  flex: 1 1 0;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.mode-btn:hover {
  color: var(--text);
}

.mode-btn.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, var(--panel));
  color: var(--text);
}

.existing-api-field {
  margin-bottom: 12px;
}

.api-combobox {
  position: relative;
}

.field .api-combobox input {
  padding-left: 33px;
}

.api-combobox-icon {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--text-faint);
  border-radius: 50%;
  transform: translateY(-62%);
  pointer-events: none;
}

.api-combobox-icon::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: -3px;
  width: 6px;
  height: 1.5px;
  border-radius: 2px;
  background: var(--text-faint);
  transform: rotate(45deg);
}

.api-combobox-results {
  position: absolute;
  z-index: 90;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.api-combobox-results[hidden] {
  display: none;
}

.api-combobox-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 8px 7px;
  color: var(--text-faint);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.api-combobox-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.api-combobox-option:hover,
.api-combobox-option.is-active {
  border-color: var(--border);
  background: var(--panel-3);
}

.api-combobox-option.is-selected {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 11%, var(--panel));
}

.api-combobox-main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.api-combobox-name {
  overflow: hidden;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.api-combobox-desc {
  overflow: hidden;
  color: var(--text-faint);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.api-combobox-lib {
  flex: 0 0 auto;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 9.5px;
  white-space: nowrap;
}

.api-combobox-empty {
  padding: 14px 10px;
  color: var(--text-faint);
  font-size: 11.5px;
  text-align: center;
}

.api-combobox-empty strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text-dim);
}

.api-combobox-more {
  padding: 7px 8px 3px;
  color: var(--text-faint);
  font-size: 10px;
  text-align: center;
}

.field-hint.is-selected {
  color: var(--accent-strong);
}

.field-hint {
  margin: 0;
  color: var(--text-faint);
  font-size: 10.5px;
  line-height: 1.4;
}

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

.check-inline {
  margin-top: 14px;
}

.is-hidden {
  display: none !important;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.action-row .btn {
  font-size: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.form-grid-narrow {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-top: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field label {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--font);
  font-size: 12.5px;
}

.field textarea {
  resize: vertical;
  font-family: var(--mono);
  font-size: 11.5px;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.fieldset {
  margin: 14px 0 0;
  padding: 10px 12px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.fieldset legend {
  padding: 0 6px;
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
}

.fieldset .checkgrid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  max-height: none;
}

.snippet {
  width: 100%;
  margin: 6px 0 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0a1018;
  color: #c8f0ff;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  resize: vertical;
}

[data-theme="light"] .snippet {
  background: #eff6ff;
  color: #0c2d48;
}

/* Paste imports */

.import-textarea {
  width: 100%;
  margin: 4px 0 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
}

.paste-summary {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-left: 3px solid var(--accent, #38bdf8);
  border-radius: 0 6px 6px 0;
  background: var(--panel-2);
  color: var(--text);
  font-size: 12.5px;
}

.paste-summary:empty {
  display: none;
}

.paste-matches {
  max-height: 132px;
  overflow-y: auto;
  margin-top: 10px;
}

.chip-muted {
  color: var(--text-faint);
}

/* Variants and native API row */

.variant-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.variant-label {
  min-width: 148px;
  color: var(--text-faint);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.variant-row .chip-list {
  margin-top: 0;
}

.variant-note {
  color: var(--text-faint);
  font-size: 10.5px;
}

/* ==========================================================================
   No-JS crawler fallback
   ========================================================================== */

.noscript-fallback {
  margin: 24px auto;
  padding: 20px 22px;
  max-width: 860px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.55;
}

.noscript-fallback h2 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 19px;
}

.noscript-fallback h3 {
  margin: 18px 0 8px;
  color: var(--text);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.noscript-categories {
  margin: 0;
  padding-left: 18px;
}

.noscript-categories li {
  margin: 4px 0;
}

.noscript-categories strong {
  color: var(--text);
}

/* ==========================================================================
   Footer
   ========================================================================== */

.app-footer {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 18px;
  padding: 7px 18px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-faint);
  font-size: 10.5px;
}

.app-footer p {
  margin: 0;
}

.footer-credit {
  max-width: 640px;
}

.footer-meta a {
  color: var(--text-dim);
}

.footer-disclaimer {
  color: var(--warn);
}

.footer-links {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

.link-btn {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 10.5px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--accent);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1180px) {
  .app-header {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "brand actions"
      "search search";
    gap: 10px 14px;
  }

  .brand {
    grid-area: brand;
  }

  .search-wrap {
    grid-area: search;
  }

  .header-actions {
    grid-area: actions;
  }
}

@media (max-width: 900px) {
  .filter-panel {
    grid-template-columns: 1fr;
  }

  .status {
    white-space: normal;
  }
}

@media (max-width: 820px) {
  body {
    overflow-y: auto;
    overflow-x: hidden;
    height: auto;
    min-height: 100%;
  }

  .catalog {
    flex: 0 0 auto;
    height: calc(100dvh - 250px);
    min-height: 360px;
  }

  .app-header {
    padding: 10px 12px;
  }

  .brand-tag {
    display: none;
  }

  .header-actions .btn:not(.icon-btn) {
    padding: 7px 9px;
    font-size: 11.5px;
  }

  .filterbar {
    padding: 7px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .status {
    flex: 1 1 100%;
  }

  .cat-tabs {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding: 8px 12px;
    flex: 0 0 auto;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--panel) 60%, transparent);
  }

  .columns {
    display: block;
    padding: 10px 12px;
    overflow: hidden;
  }

  .catcol {
    display: none;
    height: 100%;
    flex: 1 1 auto;
    border-radius: 10px;
  }

  .catcol[data-active="true"] {
    display: flex;
  }

  .catcol-head {
    border-radius: 10px 10px 0 0;
  }

  .selpanel {
    left: 10px;
    right: 10px;
    bottom: 54px;
    width: auto;
    max-height: 48vh;
  }

  .app-footer {
    padding: 6px 12px;
    font-size: 10px;
  }

  .footer-credit {
    flex: 1 1 100%;
  }

  .footer-links {
    margin-left: 0;
  }

  .dialog {
    width: 96vw;
    max-height: 92vh;
  }

  .dialog-shell {
    max-height: 92vh;
  }
}

@media (max-width: 768px) {
  .app-header {
    position: relative;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "brand"
      "actions"
      "search";
  }

  .header-actions {
    width: 100%;
    min-width: 0;
    justify-content: flex-start;
    gap: 6px;
    flex-wrap: nowrap;
  }

  .header-actions > * {
    flex: 0 1 auto;
    min-width: 0;
  }

  #theme-toggle {
    position: absolute;
    top: 10px;
    right: 12px;
    border: 0;
    background: transparent;
  }

  #about-btn,
  .catcol-head .info-btn {
    display: none !important;
  }
}

@media (max-width: 560px) {
  .app-header {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "actions"
      "search";
  }

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

  .brand-name {
    font-size: 15px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
    font-size: 15px;
  }

  .header-actions {
    gap: 5px;
  }

  .header-actions .btn:not(.icon-btn) {
    padding: 5px 6px;
    font-size: 10px;
  }

  .dialog-head,
  .dialog-meta,
  .dialog-body,
  .dialog-foot {
    padding-left: 14px;
    padding-right: 14px;
  }

  .dialog-title {
    font-size: 16px;
  }

  .export-block .export-btn {
    flex: 1 1 40%;
  }
}

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