/* TokenDrift — a reference table, not a landing page.
 *
 * Palette: cool neutral greys carrying a single teal accent, with amber for
 * "unconfirmed" and red for "needs review" so the two markers a reader must not
 * miss are the only saturated things on the page. Type is the system UI stack
 * for prose and the system mono stack for every number, at tabular figures, so
 * digits line up down a column. Nothing here loads over the network.
 */

:root {
  color-scheme: light dark;

  --bg:            #fbfbfc;
  --surface:       #ffffff;
  --surface-2:     #f4f5f7;
  --surface-3:     #eceef1;
  --border:        #e1e4e9;
  --border-strong: #c7ccd4;

  --text:   #12151a;
  --text-2: #4b5361;
  --text-3: #79818e;

  --accent:        #0d6e66;
  --accent-hover:  #0a5751;
  --accent-bg:     #e6f3f1;
  --accent-border: #a9d5cf;

  --warn:        #8a5000;
  --warn-bg:     #fdf2e0;
  --warn-border: #e5c68b;

  --danger:        #a02222;
  --danger-bg:     #fceded;
  --danger-border: #eab6b6;

  --up:   #a02222;
  --down: #0d6e66;

  --shadow: 0 1px 2px rgb(16 21 26 / 0.05), 0 1px 3px rgb(16 21 26 / 0.04);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --s-xs: 11px;
  --s-sm: 12.5px;
  --s-md: 14px;
  --s-lg: 15.5px;
  --s-xl: 20px;
  --s-2xl: 27px;

  --gap: 16px;
  --radius: 5px;
  --max: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #0e1014;
    --surface:       #14171c;
    --surface-2:     #1a1e25;
    --surface-3:     #222731;
    --border:        #262b34;
    --border-strong: #3a424f;

    --text:   #e7eaef;
    --text-2: #a4adba;
    --text-3: #737d8b;

    --accent:        #4fd1c5;
    --accent-hover:  #7ee0d6;
    --accent-bg:     #102b28;
    --accent-border: #1f4a45;

    --warn:        #f0b23c;
    --warn-bg:     #2a2113;
    --warn-border: #55411c;

    --danger:        #f28b8b;
    --danger-bg:     #2b1717;
    --danger-border: #552626;

    --up:   #f28b8b;
    --down: #4fd1c5;

    --shadow: none;
  }
}

/* --- base ---------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--s-md)/1.55 var(--sans);
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

code, .mono { font-family: var(--mono); font-size: 0.92em; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 20px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 20;
  background: var(--surface); color: var(--text);
  padding: 10px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius);
}
.skip:focus { left: 8px; top: 8px; }

/* --- header -------------------------------------------------------------- */

/* Deliberately NOT sticky. A sticky masthead and a sticky table header have to
 * agree on a pixel offset, and they stop agreeing the moment the nav wraps —
 * which leaves table rows sliding through the gap. On a page whose whole point
 * is a long table, the column headings are the ones worth pinning. */
.site-head {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.head-inner {
  display: flex; align-items: center; gap: var(--gap);
  flex-wrap: wrap;
  min-height: 52px;
  padding-top: 8px; padding-bottom: 8px;
}

.brand {
  font-family: var(--mono);
  font-size: var(--s-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 7px;
}
.brand-mark { color: var(--accent); font-size: 11px; }

.site-head nav { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; }
.site-head nav a {
  color: var(--text-2);
  text-decoration: none;
  font-size: var(--s-sm);
  letter-spacing: 0.02em;
  padding: 6px 10px;
  border-radius: var(--radius);
}
.site-head nav a:hover { color: var(--text); background: var(--surface-2); }
.site-head nav a[aria-current="page"] {
  color: var(--text); background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
}

/* --- page structure ------------------------------------------------------ */

main { padding-top: 34px; padding-bottom: 64px; }

.page-head { max-width: 68ch; margin-bottom: 26px; }

h1 {
  font-size: var(--s-2xl);
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 600;
  margin: 0 0 10px;
}

h2 {
  font-size: var(--s-xl);
  line-height: 1.25;
  letter-spacing: -0.01em;
  font-weight: 600;
  margin: 0;
}

h3 {
  font-size: var(--s-lg);
  font-weight: 600;
  margin: 0 0 6px;
}

.lede { color: var(--text-2); font-size: var(--s-lg); margin: 0; }
.lede .badge { vertical-align: 1px; }

.prose { max-width: 72ch; color: var(--text-2); }

section { margin-top: 40px; }

.section-head { margin-bottom: 14px; }
.section-note { color: var(--text-3); font-size: var(--s-sm); margin: 6px 0 0; max-width: 78ch; }

.crumbs { font-size: var(--s-sm); color: var(--text-3); margin-bottom: 12px; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs span[aria-hidden] { padding: 0 4px; color: var(--border-strong); }

.model-title { font-family: var(--mono); font-size: 24px; letter-spacing: -0.02em; word-break: break-word; }

.meta-list {
  list-style: none; display: flex; flex-wrap: wrap; gap: 6px 20px;
  padding: 0; margin: 14px 0 0;
  font-size: var(--s-sm); color: var(--text-3);
}
.meta-list b { color: var(--text-2); font-weight: 500; }

/* --- stat strip ---------------------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 28px;
}
.stat { background: var(--surface); padding: 13px 15px; }
.stat dt {
  font-size: var(--s-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 4px;
}
.stat dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.stat dd small { display: block; font-family: var(--sans); font-size: var(--s-xs); font-weight: 400; color: var(--text-3); letter-spacing: 0; margin-top: 3px; line-height: 1.4; }

/* One row, however many tiles: an auto-fit track count that lands one short
 * leaves a conspicuous hole where a fifth statistic should be. */
@media (min-width: 900px) {
  .stats { grid-template-columns: repeat(var(--tiles, 4), minmax(0, 1fr)); }
}
@media (max-width: 899px) {
  /* An odd tile count otherwise leaves a blank half-cell at the end. */
  .stats .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* --- notices ------------------------------------------------------------- */

.notice {
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-3);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 15px;
  font-size: var(--s-sm);
  color: var(--text-2);
  margin-bottom: 26px;
  max-width: 86ch;
}
.notice strong { color: var(--text); }
.notice-warn { border-left-color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn); }
.notice-warn strong { color: var(--warn); }
.notice-accent { border-left-color: var(--accent); }

.empty {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--text-3);
  font-size: var(--s-sm);
  max-width: 78ch;
}

/* --- filters ------------------------------------------------------------- */

.filters {
  display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: flex-end;
  padding: 14px 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: none;
}
.filters[hidden] { display: none; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
  font-size: var(--s-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
}
.field input[type="search"], .field select {
  font: inherit;
  font-size: var(--s-sm);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 6px 9px;
  min-width: 150px;
}
.field input[type="search"] { min-width: 210px; }

.field-checks { flex-direction: column; gap: 6px; }
.field-checks .check {
  display: flex; align-items: center; gap: 7px;
  font-size: var(--s-sm); text-transform: none; letter-spacing: 0; color: var(--text-2);
}
.field-checks input { accent-color: var(--accent); }

.field-status { margin-left: auto; flex-direction: row; align-items: center; gap: 12px; }
.filter-status { font-size: var(--s-sm); color: var(--text-3); margin: 0; font-variant-numeric: tabular-nums; }

.btn {
  font: inherit; font-size: var(--s-sm);
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 6px 12px;
  cursor: pointer;
}
.btn:hover { color: var(--text); background: var(--surface-3); }

/* --- tables -------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.filters + .table-wrap { border-radius: 0 0 var(--radius) var(--radius); }

table.data {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: var(--s-sm);
}
table.data.narrow { min-width: 520px; }
table.data.kv { min-width: 0; }

/* The index carries eight columns and 690 rows. Left to content-based sizing
 * the table grows past the viewport and pushes the two columns that ARE the
 * product — when it was verified, and what it was read from — off the right
 * edge, where a reader has to go looking for them. Fixed layout keeps them on
 * screen and truncates the long model ids instead, which carry a title. */
table.data.fixed { table-layout: fixed; min-width: 940px; }
table.data.fixed td { overflow: hidden; text-overflow: ellipsis; }

table.data thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2);
  text-align: left;
  font-weight: 500;
  font-size: var(--s-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
  padding: 0;
  border-bottom: 1px solid var(--border-strong);
}
table.data thead th:not(:has(button)) { padding: 9px 12px; }
table.data thead th .unit { text-transform: none; letter-spacing: 0; opacity: 0.7; }

table.data thead th button {
  all: unset;
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  cursor: pointer;
  color: inherit;
  font: inherit;
  white-space: nowrap;
}
table.data thead th button::after {
  content: "";
  display: inline-block;
  width: 0.7em;
  margin-left: 5px;
  opacity: 0.55;
}
table.data thead th[aria-sort="ascending"] button::after { content: "\2191"; opacity: 1; }
table.data thead th[aria-sort="descending"] button::after { content: "\2193"; opacity: 1; }
table.data thead th[aria-sort]:not([aria-sort="none"]) { color: var(--text); }
table.data thead th button:hover { background: var(--surface-3); }

table.data td { padding: 7px 12px; border-bottom: 1px solid var(--border); vertical-align: top; line-height: 1.45; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }

table.data th.num, table.data td.num { text-align: right; font-family: var(--mono); white-space: nowrap; }
table.data th.num button { text-align: right; }
table.data td.nowrap { white-space: nowrap; }

table.data.kv th { text-align: left; font-weight: 500; color: var(--text-2); white-space: nowrap; width: 1%; padding-right: 28px; }
table.data.kv td { font-family: var(--mono); }
table.data.kv td.plain { font-family: var(--sans); color: var(--text-3); }

td .model-link {
  font-family: var(--mono); text-decoration: none;
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
td .model-link:hover { text-decoration: underline; }
td .display-name {
  display: block; color: var(--text-3); font-size: 10.5px; line-height: 1.4;
  margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

td .tier { font-family: var(--mono); white-space: nowrap; }
td .variant { color: var(--text-3); font-family: var(--mono); }

td .null { color: var(--text-3); }

.stamp { font-family: var(--mono); font-size: var(--s-xs); color: var(--text-2); }

.src { text-decoration: none; display: block; max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src:hover { text-decoration: underline; }
.src-host { display: block; font-family: var(--mono); font-size: 10.5px; line-height: 1.4; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.src-name { display: block; max-width: 24ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.table-foot { font-size: var(--s-sm); color: var(--text-3); margin: 10px 0 0; max-width: 82ch; }

/* --- freshness ----------------------------------------------------------- */

.fresh { white-space: nowrap; }
.fresh .dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  margin-right: 7px; vertical-align: 1px;
  background: var(--text-3);
}
.fresh[data-age="recent"] .dot { background: var(--accent); }
.fresh[data-age="aging"]  .dot { background: var(--warn); }
.fresh[data-age="stale"]  .dot { background: var(--danger); }
.fresh[data-age="never"]  .dot { background: var(--danger); box-shadow: inset 0 0 0 2px var(--surface); }
.fresh .stamp { display: block; font-family: var(--mono); font-size: 10.5px; line-height: 1.4; color: var(--text-3); margin-left: 14px; }

/* --- badges -------------------------------------------------------------- */

.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1.5;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}
.badge + .badge { margin-left: 4px; }

.badge-warn    { color: var(--warn);   background: var(--warn-bg);   border-color: var(--warn-border); }
.badge-danger  { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.badge-ok      { color: var(--accent); background: var(--accent-bg); border-color: var(--accent-border); }
.badge-muted   { color: var(--text-3); }
.badge-vendor  { color: var(--accent); background: var(--accent-bg); border-color: var(--accent-border); }
.badge-reading { color: var(--warn);   background: var(--warn-bg);   border-color: var(--warn-border); }
.badge-unknown { color: var(--text-3); background: var(--surface-2); border-style: dashed; }

/* --- changes ------------------------------------------------------------- */

.cause-key {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 34px;
}
.cause-key-item { background: var(--surface); padding: 13px 15px; }
.cause-key-item p { margin: 8px 0 0; font-size: var(--s-sm); color: var(--text-2); }

.delta { font-family: var(--mono); white-space: nowrap; }
.delta-up   { color: var(--up); }
.delta-down { color: var(--down); }
.arrow { color: var(--text-3); padding: 0 5px; }

/* --- history ------------------------------------------------------------- */

.history-block { margin-top: 22px; }
.history-head {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.history-head h3 { font-family: var(--mono); margin: 0; }
.history-head .count { font-size: var(--s-sm); color: var(--text-3); }

.spark {
  display: block;
  width: 100%;
  max-width: 560px;
  height: 60px;
  margin: 4px 0 12px;
  overflow: visible;
}
.spark .grid { stroke: var(--border); stroke-width: 1; }
.spark .line-in  { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.spark .line-out { fill: none; stroke: var(--text-3); stroke-width: 1.5; stroke-dasharray: 3 2; }
.spark-key { font-size: var(--s-xs); color: var(--text-3); margin: -8px 0 12px; }
.spark-key .k-in::before,
.spark-key .k-out::before {
  content: ""; display: inline-block; width: 12px; height: 2px;
  margin-right: 5px; vertical-align: 3px;
}
.spark-key .k-in::before  { background: var(--accent); }
.spark-key .k-out::before { background: var(--text-3); }
.spark-key .k-out { margin-left: 14px; }

/* --- lists --------------------------------------------------------------- */

.doc-list { list-style: none; padding: 0; margin: 0; max-width: 80ch; }
.doc-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--s-sm);
  color: var(--text-2);
}
.doc-list li:last-child { border-bottom: none; }
.doc-list a.raw { font-size: var(--s-xs); color: var(--text-3); }

.limits { max-width: 80ch; padding-left: 20px; margin: 0; color: var(--text-2); font-size: var(--s-sm); }
.limits li { margin-bottom: 10px; }
.limits strong { color: var(--text); }

/* --- verbatim documents -------------------------------------------------- */

.doc-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow-x: auto;
  padding: 20px;
}
pre.doc {
  margin: 0;
  font-family: var(--mono);
  font-size: var(--s-sm);
  line-height: 1.65;
  color: var(--text-2);
  white-space: pre;
  tab-size: 4;
}

/* --- footer -------------------------------------------------------------- */

.site-foot {
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  padding: 26px 0 44px;
  color: var(--text-3);
  font-size: var(--s-sm);
}
.foot-lead { margin: 0 0 14px; max-width: 78ch; color: var(--text-2); }
.foot-links { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 20px; padding: 0; margin: 0 0 14px; }
.foot-meta { margin: 0 0 8px; max-width: 86ch; line-height: 1.5; }

/* --- responsive ---------------------------------------------------------- */

@media (max-width: 720px) {
  :root { --s-2xl: 23px; --s-xl: 18px; }
  main { padding-top: 24px; }
  .wrap { padding: 0 14px; }
  table.data thead th { top: 0; }
  .field-status { margin-left: 0; width: 100%; }
  .field input[type="search"] { min-width: 0; width: 100%; }
  .field { flex: 1 1 160px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
