:root {
  --fg: #1a1a1a;
  --muted: #666;
  --link: #0366d6;
  --bg: #fafafa;
  --card: #fff;
  --border: #e1e4e8;
  --row-alt: #f6f8fa;
  --tag-bg: #eef;
}

* { box-sizing: border-box; }

body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  margin: 0;
  color: var(--fg);
  background: var(--bg);
}

header {
  background: var(--card);
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
}

header h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

header .sub {
  margin: 0;
  color: var(--muted);
  max-width: 800px;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  padding: 16px 32px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-weight: 500;
}

.filters input, .filters select {
  font: inherit;
  color: var(--fg);
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
  min-width: 120px;
}

.filters input[type="checkbox"] {
  min-width: auto;
  margin-top: 2px;
}

/* The 3 boolean filters stack vertically as one group, each row laid out as
   "label text : checkbox" on a single line (instead of the default
   text-above-control column the other filters use). */
.filter-checkboxes {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.filter-checkboxes label {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.filter-checkboxes input[type="checkbox"] {
  margin-top: 0;
}

.summary {
  padding: 12px 32px;
  color: var(--muted);
  font-size: 13px;
}

.results {
  padding: 0 32px 24px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

th, td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--row-alt);
  font-weight: 600;
  position: sticky;
  top: 0;
}

tr:nth-child(even) td {
  background: var(--row-alt);
}

tr:hover td {
  background: #fffbe6;
}

.field {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--tag-bg);
  font-size: 12px;
  font-family: monospace;
}

.format {
  font-family: monospace;
  font-weight: 600;
}

.rank {
  font-family: monospace;
  text-align: right;
  white-space: nowrap;
}

.references {
  padding: 16px 32px 24px;
  background: var(--card);
  border-top: 1px solid var(--border);
}

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

.references .muted {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 12px;
}

.references ol {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  line-height: 1.6;
}

.references li {
  scroll-margin-top: 60px;
}

.references li:target {
  background: #fffbe6;
  padding: 2px 6px;
  border-radius: 3px;
}

.refnum {
  font-size: 10px;
}

tr.derived td {
  background: #f4f0ff;
  font-style: italic;
}

tr.derived:hover td {
  background: #e8e0ff;
}

.derived-tag {
  font-family: monospace;
  font-size: 12px;
  color: #5b3eb8;
}

.muted {
  color: var(--muted);
  font-style: italic;
}

.field-fallback {
  color: #5b3eb8;
  font-size: 10px;
  margin-left: 2px;
}

.field-narrow {
  color: #2a6a2a;
  font-size: 10px;
  margin-left: 2px;
  font-family: monospace;
}

.ref-list {
  list-style: none;
  padding-left: 0;
}
.ref-list li {
  padding-left: 0;
  margin-bottom: 4px;
}
.refnum-anchor {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #555;
  margin-right: 4px;
}

.lineage-atom-tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  color: #555;
  background: #f0f0f0;
  padding: 1px 5px;
  border-radius: 3px;
}
.lineage-formula {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  color: #333;
  background: transparent;
  word-break: break-all;
}

.lineage-compact {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  display: inline-block;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.commutative-tag {
  display: inline-block;
  padding: 1px 4px;
  border-radius: 3px;
  background: #ffe8b3;
  color: #7a4d00;
  font-family: monospace;
  font-size: 10px;
  margin-left: 4px;
}

.cmt-rank {
  color: #7a4d00;
  font-size: 11px;
}

tr.cited td {
  background: #fffae0;
}

tr.cited:hover td {
  background: #fff3b8;
}

.cited-tag {
  font-family: monospace;
  font-size: 12px;
  color: #7a4d00;
}

.refnum a {
  text-decoration: none;
}

footer {
  padding: 16px 32px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}
