:root {
  --dark-bg: #111;
  --bg: #222;
  --border: #333;
  --muted: #bbb;
  --text: #eee;
  --link: #69f;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 1.125rem;
  line-height: 1.6;
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  min-width: 0;
  background: var(--dark-bg);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0;
}

.sidebar a.site-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
}

#sidebar-filter {
  width: 100%;
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.85rem;
}

.sidebar details {
  margin-bottom: 0.75rem;
}
.sidebar-group {
  padding-left: 0.75rem;
}
.sidebar-content > ul,
.sidebar-group > ul {
  margin-bottom: 0.75rem;
}

.sidebar summary {
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text);
  cursor: pointer;
  margin-bottom: 0.25rem;
}

.sidebar ul {
  list-style: none;
  padding-left: 0.75rem;
}

.sidebar li {
  margin-bottom: 0.2rem;
}

.sidebar a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  display: block;
}

.sidebar a:hover {
  color: var(--link);
}
.sidebar a[aria-current="page"] {
  color: var(--muted);
}

main {
  min-width: 0;
  padding: 2rem 3rem;
  width: 70%;
  justify-self: center;
}

article img {
  max-width: 100%;
  height: auto;
}

.breadcrumb {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.breadcrumb a {
  color: var(--muted);
  text-decoration: none;
}
.breadcrumb a:hover {
  color: var(--link);
}

article h1 {
  font-size: 1.8rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

article h2 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}
article h3 {
  margin-top: 1.2rem;
  margin-bottom: 0.4rem;
}
article p {
  margin-bottom: 1rem;
}
article ul,
article ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

article table {
  border-collapse: collapse;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

article th,
article td {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  text-align: left;
}

article th {
  background: var(--dark-bg);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

article code {
  background: var(--dark-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
  font-size: 0.9em;
}

.backlinks {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.backlinks h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.backlinks ul {
  list-style: disc;
  padding-left: 1.5rem;
}

.backlinks li {
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

a {
  color: var(--link);
}

.term-link {
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}

.term-wrap {
  position: relative;
  display: inline;
}

.term-popover {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: var(--dark-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
  color: var(--text);
  max-width: 400px;
  width: max-content;
  overflow-wrap: break-word;
  z-index: 10;
  line-height: 1.5;
}

.term-wrap:hover .term-popover {
  display: block;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.category-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--dark-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: center;
  transition: border-color 0.15s, color 0.15s;
  gap: 0.75rem;
}

.category-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 4px;
}

.category-card:hover {
  border-color: var(--link);
  color: var(--link);
}

footer {
  grid-column: 2;
  padding: 1rem 3rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
  text-align: right;
}

/* Mobile */
@media (max-width: 768px) {
  body {
    display: block;
    min-height: auto;
    font-size: 1rem;
  }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    display: block;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }
  .sidebar-content {
    display: none;
    margin-top: 1rem;
  }
  .sidebar-header {
    margin-bottom: 0;
  }
  #menu-toggle:checked ~ .sidebar-content {
    display: block;
  }
  .menu-toggle {
    display: block;
  }
  main {
    padding: 1.5rem;
    width: 100%;
  }
  article table {
    display: block;
    overflow-x: auto;
  }
}
