/* The console's look: Relay Studio's tokens (examples/relay-simulation/d3/page.html), so the two read as one family. */
:root {
  --bg: #F2F4F6;
  --panel: #FFFFFF;
  --panel-2: #F8F9FA;
  --ink: #18202A;
  --muted: #5D6875;
  --line: #D9DEE4;
  --line-strong: #B9C1CA;
  --accent: #0E7C6B;
  --accent-ink: #FFFFFF;
  --accent-soft: #D7EEE9;
  --ask: #C2790A;
  --ask-soft: #F6E4C4;
  --hand: #A3ADB8;
  --hand-soft: #E3E7EB;
  --refuse: #B3261E;
  --refuse-soft: #F5DAD7;
  --focus: #2D6CDF;
  --focus-soft: #DCE6FA;
  --sans: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'IBM Plex Mono', 'SFMono-Regular', Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1419; --panel: #171D24; --panel-2: #1D242C; --ink: #E4E9EF; --muted: #98A3AF;
    --line: #2A3340; --line-strong: #3B4653; --accent: #3FB8A2; --accent-ink: #0F1419; --accent-soft: #163B36;
    --ask: #E5A23A; --ask-soft: #3D2E12; --hand: #4E5A67; --hand-soft: #29323C;
    --refuse: #E5655C; --refuse-soft: #3F1F1D; --focus: #7FA9F5; --focus-soft: #1B2B4A;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1419; --panel: #171D24; --panel-2: #1D242C; --ink: #E4E9EF; --muted: #98A3AF;
  --line: #2A3340; --line-strong: #3B4653; --accent: #3FB8A2; --accent-ink: #0F1419; --accent-soft: #163B36;
  --ask: #E5A23A; --ask-soft: #3D2E12; --hand: #4E5A67; --hand-soft: #29323C;
  --refuse: #E5655C; --refuse-soft: #3F1F1D; --focus: #7FA9F5; --focus-soft: #1B2B4A;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 14px; line-height: 1.45; padding: 0 16px 48px; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin: 0; }
.hint.warn { color: var(--ask); }
.wrap { word-break: break-all; }

header.top { max-width: 1320px; margin: 0 auto; padding: 18px 0 12px; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; }
header.top h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
header.top h1 a { color: var(--ink); }
header.top h1 span { color: var(--muted); font-weight: 400; }
#nav { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; flex: 1; }
#nav a { color: var(--muted); padding: 4px 0; border-bottom: 2px solid transparent; }
#nav a.active { color: var(--ink); border-color: var(--accent); text-decoration: none; }
#nav .base { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
main { max-width: 1320px; margin: 0 auto; padding-top: 16px; }

h2 { margin: 0; font-size: 18px; font-weight: 600; }
h3 { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.lede { color: var(--muted); margin: 4px 0 0; max-width: 72ch; }
.page-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; margin-bottom: 12px; }
.narrow { max-width: 560px; }
.columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 380px); gap: 16px; align-items: start; }
@media (max-width: 900px) { .columns { grid-template-columns: minmax(0, 1fr); } }
.stack { display: grid; gap: 16px; min-width: 0; }
.card { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; display: grid; gap: 10px; align-content: start; overflow-x: auto; }
.field { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 2px 10px; align-items: center; }
.field .name { font-size: 13px; }
.field .hint { grid-column: 2; font-size: 11px; }
@media (max-width: 520px) { .field { grid-template-columns: minmax(0, 1fr); } .field .hint { grid-column: 1; } }
input[type="text"], input[type="url"], input[type="password"], input[type="number"], input[type="date"], select {
  width: 100%; min-width: 0; padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--panel-2); font-size: 13px;
}
input.short { width: 72px; }
input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); justify-self: start; }
.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.inline > input[type="date"], .inline > select { width: auto; }
.inline-form { display: flex; gap: 6px; align-items: center; }
.inline-form button { white-space: nowrap; }
.check { display: inline-flex; align-items: center; gap: 6px; }
fieldset.events { border: 1px solid var(--line); border-radius: 5px; display: grid; gap: 4px; padding: 8px 10px; margin: 0; }
fieldset.events legend { font-size: 12px; color: var(--muted); padding: 0 4px; }

button { padding: 6px 12px; border: 1px solid var(--line-strong); background: var(--panel); border-radius: 5px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--ink); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--refuse); border-color: var(--refuse); background: transparent; }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
button.small { padding: 2px 8px; font-size: 12px; }
.add { border: 1px dashed var(--line-strong); background: transparent; color: var(--muted); }

table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; font-weight: 500; font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.actions { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
ul.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.tag { margin-left: 6px; padding: 0 6px; border-radius: 3px; background: var(--hand-soft); color: var(--muted); font-size: 11px; }

/* notices: the API's own words */
/* A toast, fixed: a notice must never move the grid under the pointer between two clicks. */
.notices { position: fixed; right: 16px; bottom: 16px; z-index: 10; width: min(480px, calc(100vw - 32px)); max-height: 60vh; overflow: auto; display: grid; gap: 8px; box-shadow: 0 6px 24px rgb(0 0 0 / 0.14); border-radius: 6px; }
.notices:empty { display: none; }
.notice { border: 1px solid var(--line); border-left: 4px solid var(--muted); background: var(--panel); border-radius: 5px; padding: 8px 12px; display: grid; gap: 4px; }
.notice.ok { border-left-color: var(--accent); }
.notice.refused, .notice.error { border-left-color: var(--refuse); background: var(--refuse-soft); }
.notice.secret { border-left-color: var(--ask); background: var(--ask-soft); margin-bottom: 12px; }
.notice-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.notice .detail { margin: 0; }
.notice pre { margin: 4px 0 0; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-all; }
.notice details summary { cursor: pointer; font-size: 12px; color: var(--muted); }
dl.refusal { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 12px; margin: 0; font-family: var(--mono); font-size: 12px; }
dl.refusal dt { color: var(--muted); }
dl.refusal dd { margin: 0; overflow-wrap: anywhere; }
.secret-value { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; background: var(--panel); padding: 6px 8px; border-radius: 4px; user-select: all; }

/* a World */
.world-head dl.facts { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0 0 12px; }
.facts dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.facts dd { margin: 0; }
.facts > dt + dd { margin-right: 4px; }
.world-head dl.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.live { display: inline-flex; gap: 10px; align-items: center; margin-left: auto; }
.pill { padding: 1px 8px; border-radius: 10px; font-size: 12px; border: 1px solid var(--line-strong); color: var(--muted); }
.pill.live { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.pill.polling { background: var(--ask-soft); color: var(--ask); border-color: var(--ask); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--ink); border-color: var(--accent); text-decoration: none; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin-bottom: 8px; }
.toolbar label.inline > span { color: var(--muted); font-size: 12px; }

/* the grid */
.grid-wrap.busy { opacity: 0.55; pointer-events: none; }
.grid-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px; margin: 8px 0; }
table.grid { width: auto; border-collapse: separate; border-spacing: 2px; }
table.grid th, table.grid td { padding: 0; border: 0; text-align: center; }
table.grid thead th { font-size: 10px; letter-spacing: 0; min-width: 22px; }
table.grid.bits-60 thead th { min-width: 12px; }
table.grid th.row-label { text-align: right; padding-right: 8px; white-space: nowrap; text-transform: none; letter-spacing: 0; color: var(--ink); font-weight: 400; }
.cell { display: block; width: 22px; height: 22px; padding: 0; border-radius: 3px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; }
table.grid.bits-60 .cell { width: 12px; height: 18px; border-radius: 2px; }
.cell:hover { border-color: var(--ink); }
.cell.mine { background: var(--accent); border-color: var(--accent); }
.cell.mine-soft { background: var(--accent-soft); border: 1px dashed var(--accent); }
.cell.taken { background: var(--hand); border-color: var(--hand); }
.cell.shared { background: var(--hand-soft); border-color: var(--hand); }
.cell.soft { background: repeating-linear-gradient(135deg, var(--ask-soft) 0 3px, var(--panel-2) 3px 6px); border-color: var(--ask); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i.cell { width: 14px; height: 14px; cursor: default; }

/* the journal */
ol.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: grid; gap: 10px; }
li.commit { position: relative; }
li.commit::before { content: ''; position: absolute; left: -20px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--panel); }
.commit-head { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.commit-head .hash { margin-left: auto; }
.seq { color: var(--muted); }
ul.entries { list-style: none; margin: 2px 0 0; padding: 0; display: grid; gap: 1px; font-size: 12.5px; }
.role { padding: 0 5px; border-radius: 3px; font-size: 11px; background: var(--hand-soft); }
.role.r-held { background: var(--accent-soft); color: var(--accent); }
.role.r-intent { background: var(--ask-soft); color: var(--ask); }
.set { color: var(--accent); }
.clear { color: var(--refuse); }
.chain { font-size: 12px; }
.chain.whole { color: var(--accent); }
.chain.broken { color: var(--refuse); font-weight: 600; }

/* standings: relays and asks */
.badge { display: inline-block; padding: 0 7px; border-radius: 10px; font-size: 12px; border: 1px solid var(--line-strong); color: var(--muted); }
.badge.s-asked, .badge.s-open { background: var(--ask-soft); color: var(--ask); border-color: var(--ask); }
.badge.s-held, .badge.s-accepted { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.badge.s-refused, .badge.s-rejected { background: var(--refuse-soft); color: var(--refuse); border-color: var(--refuse); }
.badge.s-mixed { background: var(--focus-soft); color: var(--focus); border-color: var(--focus); }
.strip { display: inline-flex; gap: 2px; }
.strip i, .lane-cells i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; background: var(--hand-soft); border: 1px solid var(--line); }
i.s-asked { background: var(--ask); border-color: var(--ask); }
i.s-held { background: var(--accent); border-color: var(--accent); }
i.s-refused { background: var(--refuse); border-color: var(--refuse); }
.lane-cells i { background: var(--panel-2); }
.lane-cells i.on { background: var(--hand); }
.lane-cells i.on.s-asked { background: var(--ask); }
.lane-cells i.on.s-held { background: var(--accent); }
.lane-cells i.on.s-refused { background: var(--refuse); }
.lane-cells.bits-60 i { width: 6px; }
.lanes { display: grid; gap: 3px; margin-top: 8px; overflow-x: auto; }
.lane { display: grid; grid-template-columns: 160px max-content; gap: 8px; align-items: center; }
.lane-cells { display: inline-flex; gap: 2px; }
.acts { display: flex; flex-wrap: wrap; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { padding: 2px 8px; font-size: 12px; border-radius: 10px; }
.legs { display: grid; gap: 4px; }
.leg-row { display: grid; grid-template-columns: 18px minmax(0, 1fr) 60px 60px 56px 24px; gap: 4px; align-items: center; }
.leg-row.head { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.relay-summary { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
details.told pre { font-family: var(--mono); font-size: 12px; white-space: pre-wrap; max-height: 260px; overflow: auto; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.tab-body { display: grid; gap: 16px; align-content: start; }
