/*
 * Burrow: plain CSS, embedded assets, no build step.
 * Tokens, shell and shared components. Page composition lives in
 * pages-issues.css (issue list, issue detail) and pages-admin.css
 * (projects, settings, auth, error).
 *
 * Type: five sizes only (--fs-1..--fs-5 = 13/14/16/20/32px). Sans for UI and
 * prose; IBM Plex Mono only for code, culprits, IDs, DSNs and figures.
 * Colour: red means fatal, regression or destructive, nothing else.
 * Fox: brand mark, empty states, auth/error pages and the search dig. Nowhere else.
 *   --fox (rust) belongs to the fox alone; it never marks state or severity.
 * Activity bars: .barcode > .bars > 14 span.bar.h0/h5/.../h100 (height classes,
 * never inline styles; strict CSP).
 */
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/IBMPlexMono-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/IBMPlexMono-Medium.woff2") format("woff2"); font-weight: 500 700; font-style: normal; font-display: swap; }
:root {
  color-scheme: dark;
  --bg: #0b0b0a; --surface: #121211; --surface-2: #1c1c1a;
  --text: #f2efe6; --muted: #a9a79e; --border: #2f2f2b; --rule: #706f68;
  --red: #e5322d; --red-text: #ff7a73; --blue: #8aa2ff; --warn: #e3b552; --fox: #e07a43;
  --ok-bg: #141a14; --err-bg: #221413; --code-bg: #10100f; --hit: #3d1817;
  --radius: 4px;
  --fs-1: .8125rem; --fs-2: .875rem; --fs-3: 1rem; --fs-4: 1.25rem; --fs-5: 2rem;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    /* Warm stone: a hint of the earth the fox digs in, short of cream. */
    --bg: #f2f1ee; --surface: #faf9f6; --surface-2: #e6e3dc;
    --text: #1a1916; --muted: #58564f; --border: #d5d2ca; --rule: #86847e;
    --red: #bc2621; --red-text: #a81d19; --blue: #2f49a3; --warn: #7d5200; --fox: #b4531f;
    --ok-bg: #e2e9df; --err-bg: #f4ddd8; --code-bg: #e8e5df; --hit: #f5d5cf;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--rule) var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font: var(--fs-2)/1.55 var(--sans); caret-color: var(--blue); }
::selection { color: var(--bg); background: var(--blue); }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .2em; }
a:hover { text-decoration-color: var(--blue); }
h1, h2, h3 { font-family: var(--sans); font-weight: 600; line-height: 1.25; text-wrap: balance; overflow-wrap: anywhere; }
h1 { font-size: clamp(1.5rem, 2.4vw, var(--fs-5)); letter-spacing: -.02em; margin: 0 0 .25rem; }
h2 { font-size: var(--fs-4); margin: 0 0 .75rem; }
h3 { font-size: var(--fs-3); margin: 0 0 .5rem; }
p { margin: .4rem 0 1rem; max-width: 72ch; }
code, pre, .mono { font-family: var(--mono); font-size: var(--fs-1); }
pre { margin: 0; }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
:disabled, [aria-disabled=true] { opacity: .45; cursor: not-allowed; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-1); }
.inline { display: inline; }
.js-only { display: none !important; }
.js .js-only { display: inline-flex !important; }
.js-only-inline { display: none; }
.js .js-only-inline { display: inline; }
.icon { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.skip-link { position: fixed; top: -100px; left: 12px; z-index: 5; padding: 10px 14px; color: var(--bg); background: var(--text); }
.skip-link:focus { top: 12px; }

/* Shell ------------------------------------------------------------------ */
.topbar { display: flex; align-items: center; gap: 14px; min-height: 60px; padding: 8px 24px; border-bottom: 1px solid var(--border); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; flex: 0 0 auto; }
.brand:hover { text-decoration: none; }
.brand .fox-mark { width: 34px; height: 34px; }
.brand-wordmark { font: 500 var(--fs-4)/1 var(--mono); letter-spacing: -.03em; }
.topbar-sep { color: var(--muted); }
.project-crumb { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; text-decoration: none; }
.project-crumb:hover { text-decoration: underline; }
.app-shell { display: grid; grid-template-columns: 196px minmax(0, 1fr); min-height: calc(100svh - 61px); }
.rail { position: sticky; top: 0; align-self: start; display: flex; flex-direction: column; height: calc(100svh - 60px); padding: 18px 12px; border-right: 1px solid var(--border); }
.rail-nav { display: flex; flex-direction: column; gap: 2px; }
.rail-item { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 10px; border-radius: var(--radius); color: var(--muted); text-decoration: none; }
.rail-item:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.rail-item.active { color: var(--text); background: var(--surface-2); font-weight: 600; }
.rail-account { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--border); font-size: var(--fs-1); }
.rail-email { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); text-decoration: none; }
.rail-email:hover, .rail-email.active { color: var(--text); text-decoration: underline; }
.rail-email-short { display: none; }
.rail-account form { margin-top: 4px; }
main.main, main { min-width: 0; padding: 28px 32px 56px; }
.main:focus { outline: 0; }
.rail-account button.link { display: block; min-height: 32px; color: var(--muted); }
.rail-account button.link:hover { color: var(--text); }
.rail-help { display: flex; align-items: center; min-height: 32px; color: var(--muted); }
.rail-help:hover { color: var(--text); }
.rail-version { display: block; margin-top: 10px; color: var(--muted); }
kbd { display: inline-block; min-width: 1.6em; padding: 0 5px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); font: 500 var(--fs-1)/1.6 var(--mono); text-align: center; }
.shortcuts { width: min(420px, calc(100% - 32px)); padding: 22px 24px; border: 1px solid var(--rule); border-radius: 6px; background: var(--surface); color: var(--text); box-shadow: 0 18px 50px -12px rgb(0 0 0 / .45); }
.shortcuts::backdrop { background: rgb(0 0 0 / .45); }
.shortcuts h3 { margin: 14px 0 8px; color: var(--muted); font-size: var(--fs-1); }
.shortcuts dl { display: grid; grid-template-columns: 5.5rem 1fr; gap: 8px 14px; margin: 0 0 6px; align-items: center; }
.shortcuts form { margin-top: 16px; }
.shortcuts dd { margin: 0; }
.nowrap { white-space: nowrap; }
.auth-shell { display: block; }

/* Page heading ----------------------------------------------------------- */
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.pagehead-copy p { margin: 0; }
.crumbs { margin: 0 0 14px; color: var(--muted); overflow-wrap: anywhere; }
.crumbs a { color: var(--text); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

/* Controls --------------------------------------------------------------- */
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 8px 14px; border: 1px solid var(--rule); border-radius: var(--radius); background: transparent; color: var(--text); font-size: var(--fs-2); font-weight: 500; line-height: 1.3; cursor: pointer; text-decoration: none; }
button:hover:not(:disabled), .button:hover { background: var(--surface-2); border-color: var(--text); text-decoration: none; }
.primary, button.primary { background: var(--text); border-color: var(--text); color: var(--bg); }
.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--text) 82%, var(--blue)); border-color: color-mix(in srgb, var(--text) 82%, var(--blue)); color: var(--bg); }
.destructive, .button.destructive { color: var(--red-text); border-color: var(--red); }
.destructive:hover:not(:disabled) { color: var(--bg); background: var(--red); border-color: var(--red); }
button.small, .button.small { min-height: 34px; padding: 5px 10px; font-size: var(--fs-1); }
button.link { min-height: 0; padding: 0; border: 0; background: none; color: inherit; font-weight: 400; text-decoration: underline; text-underline-offset: .2em; }
button.link:hover { background: none; color: var(--text); }
:where(input:not([type=hidden], [type=checkbox], [type=radio]), select, textarea) { width: 100%; min-width: 0; min-height: 40px; padding: 8px 11px; border: 1px solid var(--rule); border-radius: var(--radius); color: var(--text); background: var(--surface); font-size: var(--fs-2); accent-color: var(--blue); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
input::placeholder { color: var(--muted); opacity: 1; }
input[type=checkbox] { width: 18px; height: 18px; margin: 0; accent-color: var(--blue); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
.stack label.check, label.check { flex-direction: row; align-items: center; gap: 9px; font-weight: 400; }
.stack > button { align-self: flex-start; }
.help { color: var(--muted); font-size: var(--fs-1); font-weight: 400; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.alert { padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius); }
.alert.ok { background: var(--ok-bg); }
.alert.error { background: var(--err-bg); border-color: var(--red); }

/* Status tabs ------------------------------------------------------------ */
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 2px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); text-decoration: none; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--text); font-weight: 600; border-bottom-color: var(--text); }
.tab-count { min-width: 22px; padding: 0 6px; border-radius: var(--radius); background: var(--surface-2); color: var(--muted); font: 500 var(--fs-1)/1.6 var(--mono); text-align: center; font-variant-numeric: tabular-nums; }
.tab.active .tab-count { color: var(--text); }

/* Lists (issues, projects) ----------------------------------------------- */
.tracklist { min-width: 0; }
.tracklist-head { color: var(--muted); font-size: var(--fs-1); border-bottom: 1px solid var(--rule); }
.tracklist-head, .track-row { display: grid; gap: 18px; align-items: center; padding: 10px 10px; }
.track-row { min-height: 64px; border-bottom: 1px solid var(--border); text-decoration: none; }
.track-row:hover { background: var(--surface); text-decoration: none; }
.track-row:hover .track-title { text-decoration: underline; text-decoration-color: var(--blue); }
.track-row:focus-visible { outline-offset: -2px; }
.track-row > * { min-width: 0; }
.track-title { display: block; font-size: var(--fs-3); font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.track-culprit { display: block; margin-top: 2px; color: var(--muted); font: var(--fs-1)/1.5 var(--mono); overflow-wrap: anywhere; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.figure { font: 500 var(--fs-2)/1.4 var(--mono); font-variant-numeric: tabular-nums; }
.count-hot { color: var(--text); font-weight: 600; }
.cell-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } /* visible units on narrow rows; read aloud everywhere */
.track-seen { color: var(--muted); white-space: nowrap; }

/* Activity bars: real daily counts, oldest left. ------------------------ */
.barcode { min-width: 0; color: var(--text); }
/* Hairline bars, one per day, spread across the column: reads as a barcode, plots real counts. */
.bars { display: flex; align-items: flex-end; justify-content: space-between; height: 28px; }
.bar { flex: 0 0 2px; background: currentColor; }
.bar.h0 { height: 1px; background: var(--rule); }
.bar.h5 { height: 5%; } .bar.h10 { height: 10%; } .bar.h15 { height: 15%; } .bar.h20 { height: 20%; }
.bar.h25 { height: 25%; } .bar.h30 { height: 30%; } .bar.h35 { height: 35%; } .bar.h40 { height: 40%; }
.bar.h45 { height: 45%; } .bar.h50 { height: 50%; } .bar.h55 { height: 55%; } .bar.h60 { height: 60%; }
.bar.h65 { height: 65%; } .bar.h70 { height: 70%; } .bar.h75 { height: 75%; } .bar.h80 { height: 80%; }
.bar.h85 { height: 85%; } .bar.h90 { height: 90%; } .bar.h95 { height: 95%; } .bar.h100 { height: 100%; }
.barcode-axis { display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); font-size: var(--fs-1); }

/* Level and status ------------------------------------------------------- */
.level-label { display: inline-flex; align-items: center; gap: 7px; font-size: var(--fs-1); font-weight: 600; text-transform: capitalize; white-space: nowrap; }
.level-label::before { content: ""; width: 9px; height: 9px; flex: 0 0 auto; border: 1.5px solid currentColor; }
.level-fatal { color: var(--red-text); }
.level-fatal::before { background: currentColor; transform: rotate(45deg); }
.level-error { color: var(--text); }
.level-error::before { background: currentColor; }
.level-warning { color: var(--warn); }
.level-warning::before { border: 0; background: currentColor; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.level-info, .level-debug { color: var(--muted); font-weight: 500; }
.level-info::before { border-radius: 50%; }
.level-debug::before { border-style: dashed; }
.pill { display: inline-flex; align-items: center; padding: 1px 8px; border: 1px solid var(--rule); border-radius: var(--radius); color: var(--muted); font-size: var(--fs-1); font-weight: 500; line-height: 1.5; text-transform: capitalize; vertical-align: 2px; white-space: nowrap; }
.pill.regression { color: var(--red-text); border-color: var(--red); font-weight: 600; }
.status-ignored { border-style: dashed; }

/* Panels, data, code ----------------------------------------------------- */
.panel { min-width: 0; padding: 24px 0; border-top: 1px solid var(--border); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.panel-meta { color: var(--muted); font-size: var(--fs-1); }
.copybox { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 12px; margin: 12px 0 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--code-bg); min-width: 0; }
.copybox code { flex: 1; min-width: 0; overflow-wrap: anywhere; }
pre.code { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--code-bg); max-width: 100%; overflow-x: auto; font-size: var(--fs-1); line-height: 1.7; tab-size: 2; }
table { border-collapse: collapse; width: 100%; }
.kv { table-layout: auto; } /* fixed layout ignores cell widths when the table has an sr-only caption */
.kv th, .kv td { padding: 8px 8px 8px 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.kv th { width: 11rem; color: var(--muted); font: 400 var(--fs-1)/1.5 var(--mono); }
.kv td code { white-space: pre-wrap; }
.kv tr:last-child > * { border-bottom: 0; }
.stats { display: grid; grid-template-columns: minmax(0, max-content) minmax(0, 1fr); gap: 6px 14px; margin: 0; font-size: var(--fs-1); }
.stats dt { color: var(--muted); font-family: var(--mono); overflow-wrap: anywhere; }
.stats dd { margin: 0; font-family: var(--mono); overflow-wrap: anywhere; }
.empty { padding: 48px 20px 56px; text-align: center; }
.empty p { margin-left: auto; margin-right: auto; max-width: 56ch; }
.empty-fox { display: block; width: 132px; margin: 0 auto 16px; }
.empty-fox .fox { display: block; width: 100%; height: auto; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 20px; color: var(--muted); font-size: var(--fs-1); }

/* Fox art: one ink, so it works on both grounds. ------------------------- */
.fox { color: var(--fox); overflow: visible; }
.fox .fox-ink { stroke: currentColor; stroke-width: 1.2; fill: none; stroke-linecap: round; }
.fox .fox-tip, .fox .fox-ruff, .fox .fox-tail-tip { stroke: var(--text); stroke-width: 1.2; fill: none; stroke-linecap: round; }
.fox .fox-nose { fill: var(--text); }
.fox .eye-ground { fill: var(--bg); }
.fox .fox-eyes { fill: var(--text); }
.fox .hole-cover { fill: var(--bg); }
.fox .hole-ring { fill: none; stroke: var(--muted); stroke-width: 1.3; stroke-dasharray: 3 3; }
.fox .grass-ticks, .fox .dirt-mound { fill: none; stroke: var(--muted); stroke-width: 1.2; stroke-linecap: round; }
.fox .dirt-particles { fill: var(--muted); opacity: 0; }
.fox-head, .fox-ears, .fox-eyes, .dirt-particles, .dirt-mound { transform-box: fill-box; transform-origin: center bottom; }
.fox-eyes { transform-origin: center; }
@media (prefers-reduced-motion: no-preference) {
  .fox-eyes { animation: fox-blink 9s infinite; }
  .brand:hover .fox-mark, .brand:focus-visible .fox-mark { animation: fox-wiggle 460ms cubic-bezier(.16, 1, .3, 1); }
  @keyframes fox-blink { 0%, 44%, 47%, 100% { transform: scaleY(1); } 45%, 46% { transform: scaleY(.12); } }
  @keyframes fox-wiggle { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-7deg); } 65% { transform: rotate(4deg); } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}

/* Responsive shell ------------------------------------------------------- */
@media (max-width: 860px) {
  .topbar { padding: 8px 16px; }
  .app-shell { display: block; }
  .rail { position: static; height: auto; flex-direction: row; align-items: center; gap: 8px; padding: 6px 12px; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
  .rail::-webkit-scrollbar, .tabs::-webkit-scrollbar { display: none; }
  .rail-nav { flex-direction: row; }
  .rail-item { min-height: 44px; }
  .rail-account { display: flex; align-items: center; margin: 0 0 0 auto; padding: 0; border: 0; }
  .hide-narrow { display: none; }
  /* On phones the account link is a short word beside Log out. */
  .rail-email { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; white-space: nowrap; }
  .rail-email-full { display: none; }
  .rail-email-short { display: inline; }
  /* Log out lives on the Account page on phones, so the bar fits. */
  .rail-logout { display: none; }
  .tab { gap: 5px; font-size: var(--fs-1); }
  .tab-count { padding: 0 5px; }
  .rail-account form { margin: 0; }
  .rail-account button.link { min-height: 44px; padding: 0 8px; white-space: nowrap; }
  main.main, main { padding: 22px 16px 40px; }
  .pagehead { flex-wrap: nowrap; align-items: flex-start; }
  .pagehead > .button { flex: 0 0 auto; }
  .tabs { flex-wrap: nowrap; gap: 10px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  .tab { flex: 0 0 auto; }
  .js .rail-shortcuts, .rail-version { display: none !important; }
}
@media (pointer: coarse) {
  button, .button, button.small, .button.small { min-height: 44px; }
  .crumbs a, .project-crumb { display: inline-flex; align-items: center; min-height: 44px; }
}
@media (forced-colors: active) {
  .bar { background: CanvasText; }
  .level-label::before { border-color: CanvasText; }
}
@media (max-width: 420px) {
  .rail-item .icon { display: none; }
  .rail-item { padding-inline: 8px; }
}
