/* ------------------------------------------------------------------
   The results page (docs/design/d2-results.html is the visual spec).
   Light = the public site's tokens, dark = Agora navy, picked by the OS
   (prefers-color-scheme). System fonts only: the page's CSP allows no
   external font, stylesheet or image. Everything is a same-origin file.
   ------------------------------------------------------------------ */
:root {
  color-scheme: light dark;
  --paper: #fafaf7; --raised: #ffffff; --ink: #18120e; --muted: #6b625a;
  --rule: rgba(24, 18, 14, 0.09); --rule-strong: rgba(24, 18, 14, 0.2);
  --orange: #e8703c; --orange-text: #a94a1a; --orange-soft: rgba(232, 112, 60, 0.11);
  --ok: #14794f; --ok-soft: rgba(20, 121, 79, 0.09);
  --bad: #b83b22; --bad-soft: rgba(200, 68, 42, 0.07);
  --quiet: #6e655d; --quiet-soft: rgba(24, 18, 14, 0.045);
  --btn: #18120e; --btn-ink: #fafaf7; --focus: #e8703c;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0a1428; --raised: #122046; --ink: #f7f3ed; --muted: #a8b0bc;
    --rule: rgba(255, 255, 255, 0.09); --rule-strong: rgba(255, 255, 255, 0.2);
    --orange: #f07a3f; --orange-text: #f07a3f; --orange-soft: rgba(240, 122, 63, 0.15);
    --ok: #4ade80; --ok-soft: rgba(74, 222, 128, 0.1);
    --bad: #f87171; --bad-soft: rgba(248, 113, 113, 0.1);
    --quiet: #8f9bb0; --quiet-soft: rgba(255, 255, 255, 0.05);
    --btn: #f07a3f; --btn-ink: #0a1428;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--paper); color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", system-ui, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.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;
}
.fname { font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace; font-size: 13px; overflow-wrap: anywhere; }
.muted { color: var(--muted); font-size: 14px; }
p.muted { margin: 12px 0 0; }

/* ---------------- top bar ---------------- */
.bar { max-width: 920px; margin: 0 auto; padding: 18px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 650; letter-spacing: -0.01em; }
.mark { width: 28px; height: 28px; border-radius: 8px; background: var(--ink); color: var(--paper); display: grid; place-items: center; font: 700 16px/1 Georgia, serif; }
.brand em { font-style: normal; font-weight: 450; color: var(--muted); }
.who { display: flex; align-items: center; gap: 14px; font-size: 14px; color: var(--muted); min-width: 0; }
.uname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { font: inherit; color: var(--ink); background: none; border: 0; padding: 4px 0; text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 3px; cursor: pointer; }

/* ---------------- sign-in ---------------- */
.login-card {
  max-width: 440px; margin: 8vh auto 0; padding: 28px 28px 32px;
  background: var(--raised); border: 1px solid var(--rule-strong); border-radius: 14px;
}
.login-card h1 { font-size: 26px; line-height: 1.1; letter-spacing: -0.03em; margin: 0 0 8px; }
.login-card p { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.login-actions { margin-top: 14px; }
.login-aside { min-height: 22px; margin-top: 10px; font-size: 14px; }
input[type="password"], input[type="email"], .input, .search {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule-strong); border-radius: 10px; padding: 10px 12px; width: 100%;
}
.search { background: var(--raised); padding: 7px 12px; width: 220px; }
.search::placeholder, input::placeholder { color: var(--quiet); }
.btn {
  font: inherit; font-weight: 650; background: var(--btn); color: var(--btn-ink);
  border: 1px solid var(--btn); border-radius: 10px; padding: 11px 20px; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--rule-strong); padding: 6px 14px; font-weight: 600; font-size: 14px; }
.err { color: var(--bad); font-size: 14px; margin-top: 10px; min-height: 20px; }

/* ---------------- the list ---------------- */
.results { max-width: 920px; margin: 0 auto; padding: 28px 24px 64px; }
h1 { font-size: clamp(34px, 5vw, 48px); line-height: 1.05; letter-spacing: -0.035em; font-weight: 700; margin: 0; }
.lead { color: var(--muted); font-size: 16.5px; max-width: 52ch; margin: 12px 0 28px; }

.tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 8px 132px; }
.filters { display: flex; gap: 4px; flex-wrap: wrap; }
.filters button { font: inherit; font-size: 14px; color: var(--muted); background: none; border: 0; border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.filters button[aria-pressed="true"] { color: var(--ink); background: var(--quiet-soft); font-weight: 600; }
.filters b { font-weight: 500; color: var(--quiet); margin-left: 5px; }

#renderErr { margin: 8px 0 0 132px; padding: 12px 14px; border: 1px solid var(--bad); border-radius: 10px; background: var(--bad-soft); font-size: 14px; }
.err-actions { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.err-actions .when { color: var(--muted); font-size: 13px; }
.empty { margin: 18px 0 0 132px; color: var(--muted); }

.month { margin: 26px 0 6px 132px; font-size: 14px; font-weight: 600; color: var(--muted); }

/* the lane: a date gutter and a status-coloured rail, one segment per run */
.row { display: grid; grid-template-columns: 116px minmax(0, 1fr); column-gap: 16px; }
/* --rail colours the stripe; --tone colours the status word (text needs 4.5:1, the stripe does not) */
.row.ready { --rail: var(--ok); --tone: var(--ok); }
.row.running { --rail: var(--orange); --tone: var(--orange-text); }
.row.failed { --rail: var(--bad); --tone: var(--bad); }
.row.gone { --rail: var(--quiet); --tone: var(--quiet); }
.when { padding: 13px 0 0; text-align: right; font-size: 13.5px; color: var(--muted); line-height: 1.35; }
.cell { position: relative; min-width: 0; border-top: 1px solid var(--rule); }
.cell::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--rail); }
.line {
  appearance: none; background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer;
  width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 18px; align-items: baseline;
  padding: 12px 0 12px 26px;
}
.line:hover { background: var(--quiet-soft); }
.line .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.line .n small { font-weight: 400; color: var(--muted); margin-left: 8px; font-size: 13.5px; }
.notemark { margin-left: 8px; color: var(--orange-text); font-weight: 400; }
.line .k { font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.line .s { font-size: 13.5px; font-weight: 600; color: var(--tone); white-space: nowrap; min-width: 88px; text-align: right; }
.is-open .line .n { white-space: normal; overflow-wrap: anywhere; font-size: 17px; letter-spacing: -0.01em; }
.is-open .line .k { white-space: normal; text-align: right; }

.detail { padding: 2px 0 24px 26px; min-width: 0; }
.detail p { margin: 10px 0 0; max-width: 66ch; }
.terms { font-size: 14px; color: var(--muted); }
.terms b { color: var(--ink); font-weight: 600; }
.notice, .warn { font-size: 14px; color: var(--muted); }
.warn { color: var(--ink); }
.refunded { font-size: 14px; color: var(--ok); }
.why { margin-top: 10px; max-width: 62ch; }
.why p { margin: 0 0 4px; }
.why .fix { color: var(--muted); font-size: 14px; }
p.direct { font-size: 13px; color: var(--muted); margin-top: 12px; }

.key { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; margin-top: 16px; }
.tile {
  display: block; min-width: 0; text-decoration: none; background: var(--raised);
  border: 1px solid var(--rule-strong); border-radius: 12px; padding: 14px 16px; overflow-wrap: anywhere;
}
a.tile:hover { border-color: var(--ink); }
.tile strong { display: block; font-size: 15px; letter-spacing: -0.01em; }
.tile .fname { display: block; color: var(--muted); margin-top: 2px; }
.tile small { display: block; font-size: 13px; color: var(--muted); margin-top: 6px; }
.tile-main { border-color: var(--ok); background: var(--ok-soft); }

details { margin-top: 14px; }
summary { cursor: pointer; font-size: 14px; font-weight: 600; max-width: 100%; }
.all { margin-top: 10px; columns: 2; column-gap: 28px; }
.all section { break-inside: avoid; margin-bottom: 12px; }
.all h3 { font-size: 13.5px; font-weight: 600; color: var(--muted); margin: 0 0 4px; }
.frow { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; text-decoration: none; min-width: 0; }
a.frow:hover .fname { text-decoration: underline; }
.frow .sz { color: var(--quiet); font-size: 13px; white-space: nowrap; }
.nolink { color: var(--muted); }

.progress { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; font-size: 14px; color: var(--muted); }
.track { flex: 1; min-width: 120px; max-width: 340px; height: 6px; border-radius: 6px; background: var(--orange-soft); }
.track i { display: block; height: 100%; border-radius: 6px; background: var(--orange); }

.err-box {
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace; font-size: 13px;
  white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 8px; color: var(--muted);
}
#renderErr.err-box { font-family: inherit; font-size: 14px; color: var(--ink); white-space: normal; }
.detail .err { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; min-height: 0; }

.more { margin: 16px 0 0 132px; }
.more button { font: inherit; font-size: 14px; font-weight: 600; color: var(--ink); background: none; border: 1px solid var(--rule-strong); border-radius: 10px; padding: 8px 14px; cursor: pointer; }
.older { margin: 22px 0 0 132px; border-top: 1px solid var(--rule); padding-top: 14px; }
.older summary { font-weight: 600; }
.older ul { list-style: none; padding: 0; margin: 8px 0 0; font-size: 14px; }
.older li { padding: 8px 0; border-top: 1px solid var(--rule); }
.older li:first-child { border-top: 0; }
.older .n2 { font-weight: 600; overflow-wrap: anywhere; }
.older .note { margin: 2px 0 0; color: var(--muted); max-width: 62ch; }

footer { margin: 36px 0 0 132px; padding-top: 16px; border-top: 1px solid var(--rule); font-size: 13.5px; color: var(--muted); max-width: 68ch; }
footer p { margin: 0 0 8px; }

/* ---------------- recovery email, lost-token and link pages ---------------- */
.link-h2 { font-size: 18px; letter-spacing: -0.015em; margin: 22px 0 6px; }
#linkView .warn { border-radius: 10px; padding: 11px 14px; background: var(--orange-soft); margin: 14px 0 0; }
#linkView .warn ul { margin: 0; padding-left: 18px; }
#lost .btn, #linkView .btn { width: 100%; margin-top: 14px; }
#linkView .btn-sm { margin-top: 4px; }
.tokenbox {
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace; font-size: 14px;
  background: var(--quiet-soft); border: 1px solid var(--rule-strong); border-radius: 10px;
  padding: 12px; word-break: break-all; margin: 12px 0 8px; user-select: all;
}
.cmd {
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace; font-size: 13px;
  background: var(--quiet-soft); border: 1px solid var(--rule); border-radius: 8px;
  padding: 8px 10px; margin: 4px 0 8px; overflow-wrap: anywhere; user-select: all;
}
.btn-sm { font: inherit; font-size: 14px; font-weight: 650; background: var(--btn); color: var(--btn-ink); border: 0; border-radius: 9px; padding: 8px 14px; cursor: pointer; }
.plain { font: inherit; font-size: 14px; color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.nudge {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  border: 1px solid var(--rule-strong); border-left: 3px solid var(--orange); border-radius: 10px;
  padding: 12px 16px; margin: 0 0 20px; background: var(--raised);
}
.nudge p { margin: 0; font-size: 14.5px; max-width: 58ch; }
.nudge .acts { display: flex; gap: 14px; align-items: center; }
.recovery { margin: 40px 0 0 132px; max-width: 68ch; }
.recovery h2 { font-size: 22px; letter-spacing: -0.02em; margin: 0 0 4px; }
.field { border-top: 1px solid var(--rule); padding: 16px 0; }
.field h3 { font-size: 15px; margin: 0 0 2px; }
.field p { margin: 4px 0 0; font-size: 14px; color: var(--muted); max-width: 60ch; }
.inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.inline .input { min-width: 0; flex: 1 1 200px; max-width: 340px; width: auto; font-size: 15px; }
.val { font-size: 15.5px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.ok { color: var(--ok); font-weight: 600; font-size: 13.5px; margin-left: 8px; }
.pend { color: var(--orange-text); font-weight: 600; font-size: 13.5px; margin-left: 8px; }
.links { display: flex; gap: 16px; margin-top: 10px; }
.recovery .err { margin-top: 4px; }

@media (max-width: 680px) {
  .recovery { margin-left: 0; }
  .bar, .results { padding-left: 18px; padding-right: 18px; }
  .uname { display: none; }
  .tools, .month, .older, .more, footer, #renderErr, .empty { margin-left: 0; }
  .search { width: 100%; }
  /* the date gutter folds above the row instead of beside it */
  .row { grid-template-columns: minmax(0, 1fr); }
  .when { text-align: left; padding: 10px 0 0 26px; font-size: 12.5px; }
  .cell { border-top: 0; }
  .row .when { border-top: 1px solid var(--rule); }
  .line { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding-top: 6px; }
  .line .k { grid-column: 1; grid-row: 2; white-space: normal; }
  .line .s { grid-row: 1 / 3; grid-column: 2; min-width: 0; }
  .line .n small { display: block; margin: 0; }
  .is-open .line .k { text-align: left; }
  .key { grid-template-columns: minmax(0, 1fr); }
  .all { columns: 1; }
}
