:root {
  color-scheme: light;
  --bg: #f4f2ec;
  --panel: #fbfaf5;
  --ink: #0d1117;
  --muted: #6b6963;
  --line: #d6d2c8;
  --line-strong: #111111;
  --accent: #111827;
  --accent-2: #285f50;
  --warn: #a45c00;
  --blue: #174a77;
  --shadow: 4px 4px 0 #111111;
  --soft-shadow: 0 1px 0 rgba(17, 17, 17, 0.08);
  --input-bg: #ffffff;
  --warm-panel: #f7f1e6;
  --hot-bg: #dff5eb;
  --hot-ink: #09633e;
  --active-bg: #e8edf6;
  --active-ink: #2459a6;
  --quiet-bg: #fff1d7;
  --quiet-ink: #8a5200;
  --dormant-bg: #ede7e3;
  --dormant-ink: #6c5c52;
  --toggle-track: #e6e0d3;
  --toggle-knob: #111111;
}

body.theme-dark {
  color-scheme: dark;
  --bg: #11110f;
  --panel: #1b1a17;
  --ink: #f5f1e8;
  --muted: #b6afa1;
  --line: #3a3831;
  --line-strong: #f5f1e8;
  --accent: #f5f1e8;
  --accent-2: #78c6a6;
  --blue: #89bfff;
  --shadow: 4px 4px 0 #f5f1e8;
  --soft-shadow: 0 1px 0 rgba(245, 241, 232, 0.12);
  --input-bg: #24231f;
  --warm-panel: #242018;
  --hot-bg: #143628;
  --hot-ink: #9cf1c4;
  --active-bg: #172d48;
  --active-ink: #a8ccff;
  --quiet-bg: #3a2d16;
  --quiet-ink: #ffd48a;
  --dormant-bg: #2b2925;
  --dormant-ink: #c9c0b3;
  --toggle-track: #34322d;
  --toggle-knob: #f5f1e8;
}

body.theme-red {
  --accent: #c21f2f;
  --accent-2: #c21f2f;
  --blue: #b41627;
  --warn: #c21f2f;
  --line-strong: #c21f2f;
  --shadow: 4px 4px 0 #c21f2f;
  --toggle-knob: #c21f2f;
}

body.theme-dark.theme-red {
  --blue: #ff8d99;
  --line-strong: #ff5365;
  --accent: #ff5365;
  --accent-2: #ff5365;
  --shadow: 4px 4px 0 #ff5365;
  --toggle-knob: #ff5365;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "SF Mono", "Roboto Mono", "Cascadia Mono", ui-monospace, monospace;
  font-size: 14px;
  line-height: 1.45;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  align-items: flex-start;
  gap: 24px;
  min-height: 92px;
  padding: 44px 48px 14px;
  background: var(--bg);
  border-bottom: 0;
}

.brand {
  display: block;
  min-width: 0;
  color: var(--ink);
}

.brand:hover {
  text-decoration: none;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 3.4vw, 46px);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1;
  overflow-wrap: anywhere;
}

.brand small {
  color: var(--muted);
  margin-top: 12px;
  max-width: 420px;
  font-size: 13px;
}

nav {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-top: 8px;
  white-space: nowrap;
}

nav a,
button,
.secondary {
  min-height: 30px;
  padding: 0 0 4px;
  border: 0;
  border-bottom: 2px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  border-radius: 0;
  font: inherit;
  cursor: pointer;
}

.theme-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 5px;
  white-space: nowrap;
}

.switch {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.switch input {
  appearance: none;
  width: 42px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--toggle-track);
  cursor: pointer;
}

.switch input::before {
  content: "";
  display: block;
  width: 16px;
  height: 16px;
  margin: 3px;
  border-radius: 50%;
  background: var(--toggle-knob);
  transition: transform 160ms ease;
}

.switch input:checked::before {
  transform: translateX(18px);
}

.red-switch input:checked {
  background: #ffe1e5;
}

body.theme-dark .red-switch input:checked {
  background: #3a151b;
}

.count {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--warm-panel);
  color: var(--ink);
  font-size: 12px;
}

.catalog-layout,
.detail-page {
  width: min(1560px, calc(100vw - 96px));
  margin: 0 auto;
  padding: 10px 0 52px;
}

.catalog-intro,
.toolbar,
.results-head,
.side-panel,
.panel,
.empty-state {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0;
  box-shadow: var(--soft-shadow);
}

.catalog-intro {
  max-width: 760px;
  margin: 0 0 34px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.catalog-intro p {
  max-width: 720px;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
}

.toolbar {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--input-bg);
  color: var(--ink);
  font: inherit;
}

input[type="checkbox"] {
  width: auto;
  min-height: auto;
}

.search-block input {
  min-height: 44px;
  font-size: 16px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(110px, 1fr));
  gap: 10px;
}

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 16px 0;
  padding: 14px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

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

h1 {
  margin-bottom: 4px;
  font-size: 26px;
}

h2 {
  margin-bottom: 8px;
  font-size: 18px;
  letter-spacing: 0;
}

h3 {
  margin: 16px 0 6px;
  font-size: 15px;
}

p {
  color: var(--muted);
  margin-bottom: 0;
}

.telemetry-note {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: start;
}

.table-wrap,
.compare-wrap {
  position: relative;
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.tool-cards {
  display: none;
}

.table-wrap::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 13px;
  width: 1px;
  background: var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 0;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  text-transform: uppercase;
}

.tool-table {
  min-width: 1120px;
  border-collapse: separate;
  border-spacing: 0 12px;
}

.tool-table tbody tr {
  position: relative;
}

.tool-table tbody tr::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 50%;
  width: 9px;
  height: 9px;
  background: var(--accent);
  border-radius: 50%;
  transform: translateY(-50%);
  z-index: 2;
}

.tool-table tbody td {
  background: var(--panel);
  border-top: 1px solid transparent;
  border-bottom: 1px solid transparent;
}

.tool-table tbody td:first-child {
  border-left: 1px solid transparent;
  padding-left: 34px;
}

.tool-table tbody td:last-child {
  border-right: 1px solid transparent;
}

.tool-table tbody tr:hover td,
.tool-table tbody tr:focus-within td {
  border-color: var(--line-strong);
  box-shadow: 3px 3px 0 var(--line-strong);
}

.tool-cell {
  max-width: 370px;
}

.author-cell {
  max-width: 150px;
  overflow-wrap: anywhere;
}

.tool-cell a {
  display: block;
  font-weight: 800;
}

.tool-cell span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.badge,
.chip,
.activity {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  max-width: 100%;
  margin: 1px 3px 1px 0;
  padding: 3px 7px;
  border-radius: 0;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 12px;
  white-space: nowrap;
}

.chip {
  background: transparent;
  color: var(--ink);
}

.chip.muted {
  background: transparent;
  color: var(--muted);
}

.activity.hot {
  background: var(--hot-bg);
  color: var(--hot-ink);
}

.activity.active {
  background: var(--active-bg);
  color: var(--active-ink);
}

.activity.quiet {
  background: var(--quiet-bg);
  color: var(--quiet-ink);
}

.activity.dormant {
  background: var(--dormant-bg);
  color: var(--dormant-ink);
}

meter {
  display: inline-block;
  width: 72px;
  height: 8px;
  margin-right: 8px;
}

.stack-builder {
  position: sticky;
  top: 84px;
}

.side-panel {
  padding: 14px;
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.panel-head {
  margin-bottom: 14px;
}

.stack-list {
  display: grid;
  gap: 8px;
  padding-left: 20px;
}

.stack-list li a {
  display: block;
  font-weight: 800;
}

.stack-list li span,
.tradeoff {
  color: var(--muted);
  font-size: 13px;
}

.tradeoff {
  padding: 10px;
  background: var(--warm-panel);
  border: 1px solid var(--line);
  border-radius: 0;
}

.back-link {
  display: inline-block;
  margin-bottom: 14px;
}

.detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0;
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.link-row a {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--warm-panel);
}

.inline-links {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: 6px;
  font-size: 12px;
}

.score-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-content: center;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--panel);
}

.score-box span {
  color: var(--muted);
}

.score-box strong {
  font-size: 24px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.wiki-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.wiki-infobox {
  position: sticky;
  top: 24px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
}

.wiki-infobox h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  font-weight: 400;
}

.wiki-infobox p {
  margin-bottom: 16px;
}

.wiki-infobox dl div {
  grid-template-columns: 104px minmax(0, 1fr);
  padding: 7px 0;
  border-top: 1px solid var(--line);
}

.wiki-article {
  max-width: 920px;
  padding: 4px 0 30px;
}

.wiki-toc {
  width: min(360px, 100%);
  margin: 0 0 18px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.wiki-toc strong {
  display: block;
  margin-bottom: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: 400;
}

.wiki-toc ol {
  display: grid;
  gap: 3px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.wiki-section {
  padding: 22px 0;
  border-top: 1px solid var(--line);
}

.wiki-section:first-of-type {
  border-top-color: var(--line-strong);
}

.wiki-section h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  font-weight: 400;
  line-height: 1.1;
}

.wiki-section p,
.wiki-section li {
  max-width: 780px;
  font-size: 15px;
  line-height: 1.62;
}

.wiki-section p + p {
  margin-top: 12px;
}

.wiki-section ul {
  display: grid;
  gap: 7px;
  margin: 8px 0 0;
  padding-left: 20px;
}

.wiki-section .panel {
  max-width: 780px;
  margin-top: 12px;
  background: transparent;
  box-shadow: none;
}

.wiki-section .panel h2 {
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
}

.wiki-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 780px;
  margin-top: 12px;
}

.panel {
  padding: 14px;
  border-color: var(--line-strong);
}

dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

dl div {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
}

dt {
  color: var(--muted);
  font-weight: 700;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 24px;
}

.compare-table {
  min-width: 760px;
}

.compare-table th:first-child {
  width: 180px;
}

@media (max-width: 1120px) {
  .control-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .wiki-layout {
    grid-template-columns: 1fr;
  }

  .wiki-infobox {
    position: static;
  }

  .stack-builder {
    position: static;
  }
}

@media (max-width: 720px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .results-head,
  .detail-hero {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  nav {
    width: 100%;
    padding-top: 0;
    gap: 10px;
  }

  nav a {
    flex: 1;
    text-align: center;
  }

  .theme-controls {
    justify-content: space-between;
    padding-top: 0;
  }

  .switch {
    flex: 1;
    justify-content: space-between;
    min-height: 34px;
    padding: 5px 9px;
    border: 1px solid var(--line);
    background: var(--panel);
  }

  .switch input {
    width: 36px;
    height: 20px;
    min-height: 20px;
  }

  .switch input::before {
    width: 12px;
    height: 12px;
  }

  .switch input:checked::before {
    transform: translateX(16px);
  }

  .catalog-layout,
  .detail-page {
    width: min(100vw - 24px, 1560px);
    padding-top: 12px;
  }

  .topbar {
    padding: 24px 18px 8px;
  }

  .catalog-intro p {
    font-size: 14px;
  }

  .toolbar,
  .side-panel,
  .detail-hero,
  .wiki-infobox {
    box-shadow: 2px 2px 0 var(--line-strong);
  }

  .toolbar {
    padding: 14px;
  }

  input,
  select {
    min-height: 42px;
    font-size: 13px;
  }

  .search-block input {
    min-height: 44px;
    font-size: 13px;
  }

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

  .table-wrap {
    overflow: visible;
  }

  .table-wrap::before,
  .tool-table {
    display: none;
  }

  .tool-cards {
    display: grid;
    gap: 12px;
  }

  .tool-card {
    display: grid;
    gap: 12px;
    padding: 14px;
    background: var(--panel);
    border: 1px solid var(--line-strong);
    box-shadow: 3px 3px 0 var(--line-strong);
  }

  .tool-card-main {
    display: grid;
    gap: 8px;
  }

  .tool-card-main > a {
    color: var(--ink);
    font-size: 18px;
    font-weight: 900;
    line-height: 1.2;
  }

  .tool-card-main p {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
  }

  .compare-pill {
    display: inline-flex;
    grid-template-columns: none;
    align-items: center;
    justify-self: start;
    gap: 7px;
    padding: 5px 8px;
    border: 1px solid var(--line);
    color: var(--ink);
    font-size: 11px;
  }

  .compare-pill input {
    width: 16px;
    min-height: 16px;
    height: 16px;
  }

  .tool-card-meta,
  .score-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .tool-card-meta span,
  .score-strip span {
    padding: 4px 7px;
    border: 1px solid var(--line);
    color: var(--ink);
    font-size: 12px;
  }

  .score-strip b {
    margin-left: 3px;
  }

  .wiki-layout {
    gap: 16px;
  }

  .wiki-section h2 {
    font-size: 25px;
  }

  .telemetry-note {
    white-space: normal;
  }

  dl div {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}
