/* Calm, neutral palette: greys with a muted slate-blue accent */
:root {
  --bg: #f6f7f8;
  --surface: #ffffff;
  --text: #24292f;
  --muted: #646b75;
  --border: #e3e6ea;
  --accent: #4a6585;
  --accent-soft: #edf1f5;
  --row-alt: #fafbfc;
  --code-bg: #f1f3f5;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181b;
    --surface: #1d2024;
    --text: #e3e5e8;
    --muted: #9aa1ab;
    --border: #2e3237;
    --accent: #9fb3c8;
    --accent-soft: #262c33;
    --row-alt: #202328;
    --code-bg: #24282d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
}

/* Full width, just side padding */
.wrap { width: 100%; padding: 0 32px; }

/* Header / nav */
header.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
header.top .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; padding-top: 10px; padding-bottom: 10px; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
nav { display: flex; flex-wrap: wrap; gap: 4px; }
nav a {
  color: var(--muted); text-decoration: none; font-size: 14px;
  padding: 4px 10px; border-radius: 6px;
}
nav a:hover { color: var(--text); background: var(--code-bg); }
nav a[aria-current="page"] { color: var(--text); background: var(--accent-soft); font-weight: 600; }

main { padding-top: 24px; padding-bottom: 40px; overflow-wrap: anywhere; }
h1 { font-size: 30px; line-height: 1.25; margin: 8px 0 12px; }
h2 { font-size: 22px; margin: 36px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
h3 { font-size: 18px; margin: 28px 0 10px; }
/* The "📅 Snapshot: …" heading right under the title: big date */
h1 + h2, h1 + p.downloads + h2 {
  border: 0; margin-top: 4px;
  font-size: 26px; font-weight: 600; color: var(--accent);
}
a { color: var(--accent); }
hr { border: 0; border-top: 1px solid var(--border); margin: 36px 0; }
.lead { color: var(--muted); font-size: 18px; max-width: 900px; }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }

/* Tables: always 100% wide, cells wrap, never scroll sideways */
.table-wrap {
  margin: 12px 0 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden;
}
table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: break-word; }
td[align="right"], th[align="right"] { white-space: nowrap; }
th { background: var(--accent-soft); text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; }
th.sortable-col { cursor: pointer; user-select: none; }
th.sortable-col:hover { color: var(--text); }
th[data-dir="asc"]::after { content: " ▲"; font-size: 10px; }
th[data-dir="desc"]::after { content: " ▼"; font-size: 10px; }
tbody tr:nth-child(even) { background: var(--row-alt); }
tbody tr:hover { background: var(--accent-soft); }
tbody tr:last-child td { border-bottom: 0; }

/* Diagrams and CSV */
pre { background: var(--code-bg); padding: 14px 16px; border-radius: 8px; font-size: 13px; line-height: 1.45; overflow: hidden; }
pre code { background: none; padding: 0; }
pre.diagram { background: var(--surface); border: 1px solid var(--border); }
details.csv { margin: 12px 0; }
details.csv summary { cursor: pointer; color: var(--accent); font-weight: 600; }
details.csv pre { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Downloads */
.downloads { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  display: inline-block; max-width: 100%; padding: 6px 12px; border-radius: 6px; font-size: 13px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }

/* Index cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 24px; }
.card {
  display: block; padding: 18px; border-radius: 10px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
}
.card:hover { border-color: var(--accent); }
.card h2 { font-size: 17px; border: 0; margin: 0 0 4px; padding: 0; }
.card .date { color: var(--accent); font-weight: 600; font-size: 14px; margin: 0 0 8px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }

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

/* Medium screens: tighter cells so wide tables still fit */
@media (max-width: 1200px) {
  table { font-size: 13px; }
  th, td { padding: 6px 8px; }
}

/* Phones: every table row becomes a stacked card (label: value) */
@media (max-width: 900px) {
  .wrap { padding: 0 16px; }
  h1 { font-size: 24px; }
  h1 + h2, h1 + p.downloads + h2 { font-size: 20px; }
  table, thead, tbody, tr, th, td { display: block; width: 100%; }
  thead { display: none; }
  .table-wrap { background: transparent; border: 0; }
  tbody tr {
    background: var(--surface) !important; border: 1px solid var(--border); border-radius: 8px;
    margin-bottom: 10px; padding: 6px 0;
  }
  td {
    display: flex; justify-content: space-between; gap: 12px;
    border: 0; padding: 4px 12px; text-align: right !important;
  }
  td::before {
    content: attr(data-label); color: var(--muted); font-weight: 600; text-align: left; flex: 0 0 45%;
  }
  /* ASCII diagrams shrink to fit the screen width */
  pre.diagram { font-size: 2.1vw; padding: 10px; }
}
