/* Phone first (docs/plan/20): the base rules are a phone held in one
   hand; wider screens add to them at 600px and 960px. */
:root {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --line: #dddcd6;
  /* Borders of things you press or type in: 3:1 against the panel. */
  --control-line: #8a8983;
  --text: #1b1b1a;
  --muted: #5d5c57;
  --accent: #0b5cad;
  --accent-text: #ffffff;
  --ok: #17703a;
  --bad: #b3261e;
  --bad-text: #ffffff;
  --warn: #8a5a00;
  --run: #0b5cad;
  --bar: #e6e5df;
  --code-bg: #111315;
  --code-text: #e6e6e3;
  --code-line: #36363a;
  --code-muted: #a3a3a0;
  --radius: 10px;
  --nav-h: 56px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151516;
    --panel: #1f1f21;
    --line: #36363a;
    --control-line: #75757a;
    --text: #f0f0ee;
    --muted: #a3a3a0;
    --accent: #6cb2ff;
    --accent-text: #0b1420;
    --ok: #5fd08a;
    --bad: #ff8a80;
    --bad-text: #20100e;
    --warn: #f2bf5e;
    --run: #6cb2ff;
    --bar: #303034;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body.noscroll { overflow: hidden; }
a { color: var(--accent); }
.hidden { display: none !important; }
.spacer { flex: 1 1 0; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.small { font-size: .875rem; }
/* For screen readers only. */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

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

.top {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; gap: 10px;
  min-height: calc(48px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(4px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  background: var(--panel); border-bottom: 1px solid var(--line);
}
/* The keyboard is up on the sign-in screen: the header scrolls away. */
body.auth .top { position: static; }
.brand { display: inline-flex; align-items: center; min-height: 44px; font-weight: 700; color: var(--text); text-decoration: none; }
.machine {
  flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--muted); font-size: .875rem; line-height: 44px; text-decoration: none;
}
nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--panel); border-top: 1px solid var(--line);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
nav a {
  min-height: var(--nav-h); display: flex; align-items: center; justify-content: center;
  text-decoration: none; color: var(--text); font-weight: 500; font-size: .875rem;
}
nav a[aria-current="page"] { color: var(--accent); font-weight: 700; box-shadow: inset 0 3px 0 var(--accent); }
/* A device that may manage this Mac has a fourth section. */
nav.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
nav a.hidden { display: none; }
.menu-btn { width: 44px; min-height: 44px; padding: 0; border: 0; background: transparent; }
.menu-btn svg { width: 20px; height: 20px; fill: currentColor; }
.menu-items {
  display: none; position: absolute; right: max(8px, env(safe-area-inset-right)); top: calc(100% + 4px); z-index: 5;
  flex-direction: column; min-width: 220px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.menu-items.open { display: flex; }
.menu-items > * { min-height: 48px; display: flex; align-items: center; justify-content: flex-start; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-decoration: none; }
.menu-items .who { color: var(--muted); font-size: .875rem; }
.menu-items .who:empty { display: none; }

.banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: var(--panel); border-bottom: 2px solid var(--warn); font-size: .875rem;
}
.banner span { flex: 1 1 200px; }

main {
  max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px;
  padding: 16px max(16px, env(safe-area-inset-right)) calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px) max(16px, env(safe-area-inset-left));
}
body.auth main, body.nonav main { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
main:focus { outline: none; }
h1 { font-size: 1.25rem; margin: 0; overflow-wrap: anywhere; }
h2 { font-size: 1rem; margin: 0; }
p { margin: 0; }

/* ---------------------------------------------------------------- pieces */

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat { font-size: 1.25rem; font-weight: 650; }
.label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
a.more, a.back { display: inline-flex; align-items: center; min-height: 44px; font-weight: 500; text-decoration: none; }
a.back { align-self: flex-start; }

.meter { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; align-items: center; font-size: .875rem; }
.meter .track { grid-column: 1 / -1; order: 3; }
.track { height: 8px; border-radius: 4px; background: var(--bar); overflow: hidden; }
.fill { height: 100%; background: var(--accent); border-radius: 4px; }
details > summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; color: var(--accent); font-weight: 500; font-size: .875rem; }

button, .button {
  font: inherit; min-height: 44px; padding: 6px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--control-line); background: var(--panel); color: var(--text); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.danger { color: var(--bad); border-color: var(--bad); font-weight: 600; }
button.destructive { background: var(--bad); border-color: var(--bad); color: var(--bad-text); font-weight: 600; }
button.quiet { border-color: transparent; background: transparent; color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, pre:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select {
  font: inherit; font-size: max(16px, 1rem); min-height: 44px; padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--control-line); background: var(--panel); color: var(--text); min-width: 0;
}
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; margin: 0; padding: 0; accent-color: var(--accent); }
label.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
@media (pointer: coarse) { button.primary, .button.primary, dialog button { min-height: 48px; } }

.badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .875rem; white-space: nowrap; }
.glyph { position: relative; flex: none; width: 14px; height: 14px; }
.glyph::before { content: "●"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; line-height: 1; }
.s-succeeded { color: var(--ok); } .s-succeeded .glyph::before { content: "✓"; }
.s-failed, .s-timed_out, .s-lost { color: var(--bad); }
.s-failed .glyph::before, .s-timed_out .glyph::before, .s-lost .glyph::before { content: "✕"; }
.s-flaky { color: var(--warn); } .s-flaky .glyph::before { content: "≈"; }
.s-cancelled, .s-skipped { color: var(--muted); } .s-cancelled .glyph::before, .s-skipped .glyph::before { content: "–"; }
.s-queued, .s-blocked { color: var(--warn); } .s-queued .glyph::before, .s-blocked .glyph::before { content: "…"; }
/* Drawn, not a font glyph: fallback fonts render the half circle as a dot. */
.s-running { color: var(--run); }
.s-running .glyph::before { content: ""; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: no-preference) { .s-running .glyph::before { animation: spin 1.2s linear infinite; } }

.notice { padding: 12px 14px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.notice.bad { border-color: var(--bad); color: var(--bad); }
.notice.warn { border-color: var(--warn); }
.notice button { margin-top: 8px; }
.state { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 32px 16px; text-align: center; }
.state h2 { font-size: 1.25rem; }
.state .choices { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 320px; }
.state .why { font-size: .8125rem; color: var(--muted); overflow-wrap: anywhere; }
.skeleton { height: 72px; border-radius: var(--radius); background: var(--bar); }

.cmd { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 12px; border-radius: 8px; background: var(--code-bg); }
.cmd code { flex: 1 1 0; min-width: 0; color: var(--code-text); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; overflow-wrap: anywhere; }
.cmd button { border: 0; background: #303034; color: var(--code-text); font-size: .875rem; font-weight: 600; }

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

/* One markup for every width: a card of two or three lines on a phone,
   columns from 960px. Never a table that scrolls sideways. */
.list { display: flex; flex-direction: column; }
.list-head { display: none; }
.item {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 0; min-width: 0;
  border-top: 1px solid var(--line); color: var(--text); text-decoration: none;
}
.list > .item:first-child { border-top: 0; }
a.item:active { background: var(--bar); }
.item.run { min-height: 72px; justify-content: center; }
.item-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; }
.when { color: var(--muted); font-size: .875rem; white-space: nowrap; }
.item-title { font-weight: 600; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.item-meta { display: flex; min-width: 0; color: var(--muted); font-size: .875rem; white-space: nowrap; }
.item-meta > * { flex: none; }
.item-meta > * + *::before { content: "·"; margin: 0 6px; font-family: var(--sans); font-size: .875rem; }
.item-meta .ref, .item-meta .proj, .item-meta .id { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.item-meta .is-push { display: none; }
.item .figure { font-weight: 600; white-space: nowrap; }
.item.test .id { overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 6px 0 0; }
.kv dt { color: var(--muted); font-size: 12px; }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.kv .low { color: var(--bad); font-weight: 600; }

/* ---------------------------------------------------------------- a run */

.run-head { display: flex; flex-direction: column; gap: 10px; }
.run-title { display: flex; flex-direction: column; gap: 4px; }
.run-meta { display: flex; flex-direction: column; gap: 2px; font-size: .875rem; }
/* Two fixed places: Cancel on the left, Run again on the right. A button
   never appears where another one just was. */
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.actions button { min-height: 48px; width: 100%; }
/* Tests of a run: one bar, one line of words, the flows. */
.testbar { display: flex; gap: 2px; height: 8px; border-radius: 4px; overflow: hidden; background: var(--bar); }
.testbar .seg { flex: 1 0 4px; min-width: 4px; }
.testbar .passed { background: var(--ok); }
.testbar .flaky { background: var(--warn); }
.testbar .failed { background: var(--bad); }
.testbar .skipped { background: var(--muted); }
.tests-words { margin: 0; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 14px; border-radius: 22px; }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; }
.test-row .item-title { font-weight: 600; font-size: .9375rem; }
.live-row { padding: 8px 0; }
.tests .live .track .fill { background: var(--run); }
/* Tests over a period: a column a day, and a line a flow. */
.daybars { display: flex; align-items: flex-end; gap: 6px; height: 96px; }
.daybars .day { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: .75rem; }
.daybars .well { flex: 1; width: 100%; max-width: 40px; display: flex; align-items: flex-end; background: var(--bar); border-radius: 4px; overflow: hidden; }
.daybars .col { width: 100%; background: var(--ok); display: flex; flex-direction: column; }
.daybars .bad { background: var(--bad); }
.daybars.many { gap: 2px; } .daybars.many .day span { display: none; }
.item.flow { gap: 6px; min-height: 56px; }
.item.flow .fill { background: var(--ok); } .item.flow .fill.part { background: var(--warn); }
.item.flow .aside { color: var(--warn); font-weight: 600; }
.test-actions { display: flex; gap: 20px; }
a.history { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; }
a.history::after { content: " ›"; white-space: pre; }
h1.flow-name { overflow-wrap: anywhere; font-size: 1.375rem; }
.flow-platforms h3 { margin: 4px 0 0; font-size: .875rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
/* A flow's last runs: one mark each, told apart by shape too. */
.marks { display: flex; flex-wrap: wrap; gap: 4px; }
.mark { width: 12px; height: 12px; border-radius: 50%; background: var(--ok); }
.mark.m-flaky { background: var(--warn); border-radius: 2px; transform: rotate(45deg) scale(.85); }
.mark.m-failed, .mark.m-error { background: var(--bad); border-radius: 2px; }
.mark.m-skipped { background: transparent; border: 2px solid var(--muted); }
.test-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
button.details { align-self: flex-start; min-height: 44px; padding-left: 0; color: var(--accent); }
button.details::after { content: " ▸"; }
button.details[aria-expanded="true"]::after { content: " ▾"; }
.test-more { padding: 4px 0 8px; }
.test-more .notice { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.item-tests { color: var(--muted); font-size: .875rem; }
.item-tests.has-failed { color: var(--bad); font-weight: 600; }
.split { display: flex; flex-direction: column; gap: 12px; }
.jobs { padding-top: 4px; padding-bottom: 4px; }
.jobs.few summary { display: none; }
.job {
  display: flex; justify-content: space-between; gap: 8px; width: 100%; min-height: 48px; padding: 0 4px;
  text-align: left; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent; overflow-wrap: anywhere;
}
.joblist > .job:first-child { border-top: 0; }
.job[aria-pressed="true"] { font-weight: 700; padding-left: 12px; box-shadow: inset 3px 0 0 var(--accent); }
.detail { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.logbox { position: relative; display: flex; flex-direction: column; min-width: 0; background: var(--code-bg); border-radius: 8px; overflow: hidden; }
.logbar { display: flex; align-items: center; gap: 4px; padding: 0 4px; border-bottom: 1px solid var(--code-line); }
.logbar button { border: 0; background: transparent; color: var(--code-text); font-size: .875rem; font-weight: 500; padding: 6px 10px; }
.logbar button[aria-pressed="true"]::before { content: "✓"; }
.logbar .follow { margin-left: auto; padding-right: 10px; color: var(--code-muted); font-size: 13px; white-space: nowrap; }
.logtitle { display: none; flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 12px; color: var(--code-text); font-weight: 600; }
pre.log {
  margin: 0; padding: 12px; border-radius: 8px; background: var(--code-bg); color: var(--code-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 62vh; overflow: auto; overscroll-behavior: contain;
}
/* dvh: on a phone the address bar comes and goes. */
.logbox pre.log { border-radius: 0; max-height: none; height: 60vh; height: min(60dvh, 520px); min-height: 200px; }
.logbox.nowrap pre.log { white-space: pre; overflow-wrap: normal; }
.jump {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  border: 0; border-radius: 22px; padding: 0 16px; white-space: nowrap;
  background: #6cb2ff; color: #0b1420; font-size: .875rem; font-weight: 600;
}
.logbox.full {
  position: fixed; inset: 0; z-index: 10; border-radius: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.logbox.full pre.log { flex: 1 1 0; height: auto; min-height: 0; }
.logbox.full .logtitle { display: block; }
.logbox.full .jump { bottom: calc(12px + env(safe-area-inset-bottom)); }

.evidence { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.evidence figure { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.evidence video, .evidence img { width: 100%; max-height: 70vh; max-height: min(70dvh, 560px); object-fit: contain; border-radius: 8px; background: #000; }
.evidence button.shot { padding: 0; border: 0; background: transparent; min-height: 0; display: block; }
.evidence figcaption { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.files { display: flex; flex-direction: column; gap: 10px; }
.file { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.file .name { overflow-wrap: anywhere; }
.file .do { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; align-items: center; }

/* ---------------------------------------------------------------- dialogs */

dialog { padding: 0; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: calc(100% - 32px); max-width: 420px; }
dialog::backdrop { background: rgba(17, 19, 21, .55); }
dialog .sheet { padding: 20px 16px; display: flex; flex-direction: column; gap: 6px; }
dialog h2 { font-size: 1.25rem; }
dialog .choices { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
dialog .choices button { font-weight: 600; }
dialog .choices button.safe { border: 2px solid var(--accent); }
/* Run…: a form in the sheet. Two answers side by side, the safe one first. */
dialog .choices.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
dialog .choices.two > button.hidden + *, dialog .choices.two > :only-child { grid-column: 1 / -1; }
dialog.runsheet .sheet, dialog.formsheet .sheet { gap: 12px; }
dialog.runsheet .stack > p, dialog.formsheet .stack > p { margin: 0; }
dialog.formsheet input[type="text"] { width: 100%; }
/* Settings: rows that lead somewhere, cards that hold a project or a device. */
a.item.setting { min-height: 64px; justify-content: center; }
a.item.setting .when::after { content: " ›"; }
.item.device { min-height: 64px; justify-content: center; }
.item.device .badge { margin-left: 8px; font-weight: 500; }
.project h2 { overflow-wrap: anywhere; }
form.card input { width: 100%; }
/* Inside the app's Settings window: the window has its own title and
   sidebar, so the page shows its content and nothing around it. */
html.in-app .top, html.in-app nav, html.in-app a.back, html.in-app main > h1 { display: none; }
html.in-app body { padding-bottom: 0; }
/* Advanced: a line for each topic; what it holds shows when it is opened. */
details.adv > summary { color: var(--text); font-size: 1rem; font-weight: 400; justify-content: space-between; gap: 12px; min-height: 56px; }
details.adv .adv-title { display: flex; flex-direction: column; min-width: 0; }
details.adv[open] > summary { margin-bottom: 8px; }
details.adv form input { width: 100%; }
details.adv dl.kv { grid-template-columns: minmax(0, 1fr); }
details.adv dl.kv dd { overflow-wrap: anywhere; }
pre.log.about { max-height: none; white-space: pre-wrap; }
.item.key .item-top, .item.secret .item-top { gap: 8px; }
/* Right now: three short lists in one sheet; it scrolls, the page does not. */
dialog.nowsheet { max-width: 720px; }
dialog.nowsheet .sheet { gap: 14px; max-height: 85dvh; overflow-y: auto; overscroll-behavior: contain; }
dialog.nowsheet h3 { margin: 0; font-size: .875rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
dialog.nowsheet a.item { min-height: 44px; justify-content: center; }
.item-why { font-size: .875rem; }
button.nowmore { align-self: flex-start; padding-left: 0; color: var(--text); text-align: left; }
.fieldset { display: flex; flex-direction: column; gap: 6px; }
.fieldset .name, fieldset.options > legend { font-weight: 500; font-size: .875rem; color: var(--muted); padding: 0; }
.fieldset select { width: 100%; }
fieldset.options { margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; min-width: 0; }
fieldset.options > legend { margin-bottom: 6px; }
fieldset.options .option { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 4px 12px; border: 1px solid var(--control-line); border-bottom-width: 0; background: var(--panel); cursor: pointer; }
fieldset.options .option:first-of-type { border-radius: 10px 10px 0 0; }
fieldset.options .option:last-of-type { border-bottom-width: 1px; border-radius: 0 0 10px 10px; }
fieldset.options .option:only-of-type { border-radius: 10px; }
fieldset.options .option input { flex: none; width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--accent); }
fieldset.options .option > span { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
/* Overview: what is happening now, and the one thing to do. */
.now .stat a { color: inherit; display: inline-flex; align-items: center; min-height: 44px; }
button.wide { width: 100%; }
a.lastrun { display: flex; align-items: center; min-height: 44px; }
details.thismac > summary { color: var(--text); font-size: 1rem; }
details.thismac[open] > summary { margin-bottom: 4px; }
details.thismac h2 { font-size: 1rem; }
dialog.viewer { width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; border: 0; border-radius: 0; background: #000; color: #fff; }
dialog.viewer img { width: 100%; height: 100%; object-fit: contain; touch-action: pinch-zoom; display: block; }
dialog.viewer .close { position: absolute; top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); background: rgba(17, 19, 21, .7); color: #fff; border-color: #75757a; }
dialog.viewer .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: rgba(17, 19, 21, .7); font-size: 12px; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- sign-in, relay */

.login { width: 100%; max-width: 440px; margin: 4vh auto 0; display: flex; flex-direction: column; gap: 12px; }
.login form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; gap: 8px; }
.login ol.steps { margin: 0; padding-left: 1.4em; display: flex; flex-direction: column; gap: 6px; }
.login details.card > summary { color: var(--text); font-size: 1rem; }
.login details.card[open] { display: flex; flex-direction: column; gap: 12px; }
.field input { flex: 1 1 0; }
label.name { font-weight: 500; }
input.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 20px; letter-spacing: .08em; text-transform: uppercase; min-height: 48px; width: 100%; }
.mac .name { overflow-wrap: anywhere; min-width: 0; }
.mac .do { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: start; }
.mac details > summary { justify-content: center; min-width: 72px; padding: 0 12px; border: 1px solid var(--control-line); border-radius: 8px; color: var(--text); list-style: none; }
.mac details > summary::-webkit-details-marker { display: none; }
.mac details[open] { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 8px; }
.claim { display: flex; flex-direction: column; gap: 10px; }
.claim .go { display: flex; flex-direction: column; gap: 8px; }

/* ---------------------------------------------------------------- 600px and wider */

@media (min-width: 600px) {
  .top { gap: 16px; min-height: 56px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .machine { flex: 0 1 auto; max-width: 32ch; }
  nav { position: static; display: flex; gap: 4px; margin-right: auto; padding: 0; border: 0; background: none; }
  nav a { min-height: 44px; padding: 0 12px; font-size: 1rem; }
  nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--accent); }
  body.nonav .machine { margin-right: auto; }
  .menu-btn { display: none; }
  .menu-items { display: flex; position: static; flex-direction: row; align-items: center; gap: 4px; min-width: 0; padding: 0; border: 0; box-shadow: none; background: none; }
  .menu-items > * { min-height: 44px; }
  .menu-items button { color: var(--muted); }
  main { padding-bottom: calc(24px + env(safe-area-inset-bottom)); gap: 16px; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .filters { display: flex; }
  .meter { grid-template-columns: 150px minmax(0, 1fr) auto; }
  .meter .track { grid-column: auto; order: 0; }
  .run-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; align-items: start; }
  .run-title, .run-meta, .action-error { grid-column: 1; }
  .actions { grid-column: 2; grid-row: 1 / span 2; grid-template-columns: repeat(2, 150px); }
  pre.log { font-size: 12.5px; }
  .evidence { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .file { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; }
  .file .do { display: flex; }
  .item.wf { flex-direction: row; align-items: center; justify-content: space-between; gap: 16px; }
  .item.wf .kv { width: 380px; flex: none; margin: 0; }
  .claim .go { flex-direction: row; }
  input.code { width: 14ch; }
}
@media (min-width: 768px) {
  .split { flex-direction: row; align-items: flex-start; }
  .jobs { flex: 1 1 260px; max-width: 360px; }
  .detail { flex: 999 1 480px; }
}
/* A phone on its side: height is what is scarce. */
@media (orientation: landscape) and (max-height: 480px) {
  .top { position: static; min-height: 44px; }
  .logbox pre.log { height: calc(100vh - 120px); height: calc(100dvh - 120px); }
  .evidence video, .evidence img { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
}
@media (min-width: 960px) {
  :root { font-size: 15px; }
  h1 { font-size: 22px; }
  a.item:hover { background: var(--bar); }
  .runs .list-head, .item.run {
    display: grid; grid-template-columns: 130px minmax(0, 1fr) minmax(0, 240px) 150px 150px 110px; column-gap: 12px;
  }
  .list-head { padding: 0 0 8px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
  .list-head .right { text-align: right; }
  .item.run {
    grid-template-areas: "status title ref event dur when" "status proj sha event dur when";
    align-items: center; row-gap: 0; min-height: 56px; padding: 6px 0;
  }
  .item.run .item-top, .item.run .item-meta { display: contents; }
  .item.run .item-meta > * + *::before { content: none; }
  .item.run .badge { grid-area: status; }
  .item.run .item-title { grid-area: title; }
  .item.run .proj { grid-area: proj; }
  .item.run .ref { grid-area: ref; color: var(--text); font-size: 1rem; }
  .item.run .sha { grid-area: sha; }
  .item.run .event { grid-area: event; display: block; color: var(--text); font-size: 1rem; }
  .item.run .dur { grid-area: dur; text-align: right; color: var(--text); font-size: 1rem; }
  .item.run .when { grid-area: when; text-align: right; }
  /* The counts sit under the project, in the title's column. */
  .item.run { grid-template-areas: "status title ref event dur when" "status proj sha event dur when" "status tests tests tests tests tests"; }
  .item.run .item-tests { grid-area: tests; }
}
@media (max-width: 599px) {
  /* Under the thumb. */
  dialog.confirm { margin: auto 0 0; width: 100%; max-width: none; border-radius: 16px 16px 0 0; border-bottom: 0; }
  dialog.confirm .sheet { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .menu-items > button { width: 100%; }
}
