:root {
  color-scheme: light;
  --bg: #fbfaf7;
  --fg: #1d1c1a;
  --muted: #6e6a63;
  --line: #e4e0d8;
  --accent: #e8590c;
  --accent-fg: #fff;
  --chip: #f0ece4;
  --chip-hover: #e4ddd0;
}
/* Dark follows the system unless the switch has stored an explicit choice in data-theme. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #171614;
    --fg: #ecebe8;
    --muted: #9b968d;
    --line: #2e2c28;
    --accent: #ff7a2e;
    --accent-fg: #171614;
    --chip: #262420;
    --chip-hover: #34312b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171614;
  --fg: #ecebe8;
  --muted: #9b968d;
  --line: #2e2c28;
  --accent: #ff7a2e;
  --accent-fg: #171614;
  --chip: #262420;
  --chip-hover: #34312b;
}

* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
} /* elements toggled with .hidden must stay hidden even when styled with display */
body {
  margin: 0 auto;
  max-width: 60rem;
  padding: 1.5rem 1rem 4rem;
  background: var(--bg);
  color: var(--fg);
  font:
    15px/1.45 system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
}
a {
  color: inherit;
}
.muted {
  color: var(--muted);
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1rem;
}
h1 {
  margin: 0;
  font-size: 1.5rem;
}
h1 {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  white-space: nowrap;
}
.mark {
  width: 1.1em;
  height: 1.1em;
  color: var(--accent);
  flex: none;
}
header p {
  margin: 0;
  font-size: 0.85rem;
}
header p a {
  color: inherit;
}
.home {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  color: inherit;
  text-decoration: none;
}

.prose {
  max-width: 40rem;
  margin-top: 1.5rem;
  line-height: 1.6;
}
.prose h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}
.prose h3 {
  margin: 1.5rem 0 0.25rem;
  font-size: 1rem;
}
.prose p,
.prose ul {
  margin: 0.5rem 0;
}
.prose ul {
  padding-left: 1.25rem;
}

.theme {
  margin-left: auto;
  align-self: center;
}
.theme button {
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
}

/* Narrow screens: title and theme control share the first row, the status line goes underneath. */
@media (max-width: 40rem) {
  header {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0.35rem 1rem;
  }
  header p {
    grid-row: 2;
    grid-column: 1 / -1;
  }
  .theme {
    justify-self: end;
  }
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 1.25rem 0 1rem;
}
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.seg button {
  white-space: nowrap;
  border: 0;
  border-right: 1px solid var(--line);
  background: none;
  color: var(--fg);
  padding: 0.35rem 0.75rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.seg button:last-child {
  border-right: 0;
}
.seg button:hover {
  background: var(--chip);
}
.seg button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-fg);
}

#filter {
  margin: 0 0 0.75rem;
}
#coverage {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
}

#posts {
  list-style: none;
  margin: 0;
  padding: 0;
}
#posts > li {
  display: grid;
  grid-template-columns: 2.5rem 1fr;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}
.rank {
  color: var(--muted);
  text-align: right;
  padding-right: 0.6rem;
  font-variant-numeric: tabular-nums;
}
.title {
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.title:hover {
  text-decoration: underline;
}
.domain {
  color: var(--muted);
  font-size: 0.85rem;
  margin-left: 0.3rem;
}
/* Tags share the meta line and wrap below it when the row is too narrow. */
.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.75rem;
  margin-top: 0.1rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.meta a {
  color: var(--muted);
}
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.tag {
  border: 0;
  border-radius: 999px;
  background: var(--chip);
  color: var(--fg);
  padding: 0.1rem 0.6rem;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}
.tag:hover {
  background: var(--chip-hover);
}
.tag.active {
  background: var(--accent);
  color: var(--accent-fg);
}

.toggle {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: none;
  color: var(--fg);
  padding: 0.35rem 0.75rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.toggle:hover {
  background: var(--chip);
}
.toggle[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.variants {
  margin-top: 0.4rem;
  padding: 0.4rem 0.6rem;
  border-left: 2px solid var(--line);
  display: grid;
  gap: 0.25rem;
}
.variant {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
}
.variant-name {
  min-width: 11rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.tag.plain {
  cursor: default;
}
.tag.plain:hover {
  background: var(--chip);
}

#more {
  display: block;
  margin: 1.25rem auto 0;
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: none;
  color: var(--fg);
  font: inherit;
  cursor: pointer;
}
#more:hover {
  background: var(--chip);
}

footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
}
footer a {
  color: inherit;
}

@media (max-width: 30rem) {
  #posts > li {
    grid-template-columns: 2rem 1fr;
  }
  .seg button {
    padding: 0.35rem 0.55rem;
  }
}

/* Smallest phones (~360px and under): keep each control on one row. */
@media (max-width: 23rem) {
  h1 {
    font-size: 1.3rem;
  }
  .seg button {
    padding: 0.3rem 0.45rem;
    font-size: 0.85rem;
  }
  .theme button {
    padding: 0.2rem 0.45rem;
    font-size: 0.75rem;
  }
}
