/*
 * One page, one stylesheet, with the tokens and scales of the benches beside it.
 * A machine-produced fact -- an address, an identity, a value -- is set in the
 * mono face.
 *
 * This file is downloaded by whoever opens the page, comments included.
 */

:root {
  --ink: #17191c;
  --ink-quiet: #4a4f57;
  --ink-faint: #767c86;
  --page: #f7f8fa;
  --card: #ffffff;
  --edge: #dfe3e8;
  --accent: #1a5fb4;
  --bad: #b3261e;
  --good: #1c7c48;
  --waiting: #8a5a00;
  /* A value that went down since the first reading. Orange, as asked, and dark
     enough to read on white. */
  --falls: #c05600;

  --text-caption: 0.75rem;
  --text-small: 0.85rem;
  --text-body: 0.95rem;
  --text-lead: 1.1rem;
  --text-title: 1.5rem;

  --control: 34px;

  --gap-xs: 4px;
  --gap-s: 8px;
  --gap-m: 12px;
  --gap-l: 20px;
  --gap-xl: 32px;

  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: var(--gap-xl) var(--gap-l);
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--text-body);
  line-height: 1.5;
}

main, .masthead { max-width: 1200px; margin: 0 auto; }
.masthead h1 { font-size: var(--text-title); margin: 0 0 var(--gap-xs); font-weight: 600; }
.lede { margin: 0 0 var(--gap-l); color: var(--ink-quiet); max-width: 70ch; }
.row.top { align-items: flex-start; }

.who { display: flex; gap: var(--gap-m); align-items: center; font-size: var(--text-small); }
.badge {
  font-size: var(--text-caption);
  color: var(--ink-quiet);
  border: 1px solid var(--edge);
  border-radius: 999px;
  padding: 0 var(--gap-s);
}

.panel {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: 8px;
  padding: var(--gap-l);
  margin-bottom: var(--gap-l);
}
.narrow-card { max-width: 24rem; margin-left: auto; margin-right: auto; }
body:not(.signed-in) .masthead { max-width: 24rem; }

.heading { font-size: var(--text-lead); font-weight: 600; margin: var(--gap-xl) 0 var(--gap-m); }
.panel .heading { margin-top: 0; }
.note { color: var(--ink-quiet); margin: 0 0 var(--gap-m); }

.field { display: block; margin-bottom: var(--gap-m); }
.label { display: block; font-size: var(--text-small); color: var(--ink-quiet); margin-bottom: var(--gap-xs); }
.hint { color: var(--ink-faint); font-weight: 400; }

input[type=text], input[type=password], input[type=email], input[type=number], select {
  width: 100%;
  font-family: var(--font-mono);
  font-size: var(--text-small);
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: 6px;
  padding: var(--gap-s) var(--gap-m);
  height: var(--control);
}
select { font-family: var(--font); cursor: pointer; }
input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.row { display: flex; gap: var(--gap-m); align-items: flex-end; flex-wrap: wrap; }
.row .field { margin-bottom: 0; }
.narrow { width: 11rem; }
.minutes { width: 15rem; }
.grow { flex: 1 1 240px; }

button {
  font: inherit;
  font-size: var(--text-small);
  padding: 0 var(--gap-l);
  height: var(--control);
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button[disabled] { opacity: 0.6; cursor: default; }
button.quiet { background: var(--card); color: var(--accent); border-color: var(--edge); }
button.quiet:hover { filter: none; border-color: var(--accent); }
button.danger { background: var(--bad); }
button.small { height: 28px; padding: 0 var(--gap-m); }
button.wide { width: 100%; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.privacy { margin: var(--gap-m) 0 0; font-size: var(--text-caption); color: var(--ink-faint); max-width: 80ch; }
.empty { color: var(--ink-faint); font-size: var(--text-small); margin: var(--gap-m) 0 0; }

.refusal, .notice {
  background: var(--card);
  border: 1px solid var(--bad);
  border-left-width: 4px;
  border-radius: 6px;
  padding: var(--gap-m) var(--gap-l);
  margin: var(--gap-m) 0 var(--gap-l);
  color: var(--bad);
}
.notice { border-color: var(--edge); border-left-color: var(--accent); color: var(--ink-quiet); }

.tabs { display: flex; gap: var(--gap-xs); margin-bottom: var(--gap-l); border-bottom: 1px solid var(--edge); }
.tab {
  background: none;
  color: var(--ink-quiet);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0 var(--gap-m);
}
.tab:hover { filter: none; color: var(--accent); }
.tab.is-active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

.invited { margin-top: var(--gap-l); }

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

.sheet {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: 8px;
  overflow-x: auto;
}
.rows { width: 100%; border-collapse: collapse; font-size: var(--text-small); }
.rows th, .rows td {
  text-align: left;
  padding: var(--gap-s) var(--gap-m);
  border-bottom: 1px solid var(--edge);
  white-space: nowrap;
}
.rows th {
  font-size: var(--text-caption);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  font-weight: 600;
}
.rows tbody tr:last-child td { border-bottom: none; }
.rows .mono { font-family: var(--font-mono); }
.rows .num { text-align: right; }
.rows .action { text-align: right; width: 1%; }
.rows tr.is-disabled td { color: var(--ink-faint); }
#sessions tbody tr { cursor: pointer; }
#sessions tbody tr:hover { background: var(--page); }

.state-word.is-searching, .state-word.is-connecting { color: var(--waiting); }
.state-word.is-reading { color: var(--good); }
.state-word.is-ended { color: var(--ink-faint); }

/* ------------------------------------------------------------- one session */

.detail-head { align-items: center; margin-bottom: var(--gap-l); }
.detail-head h2 { font-family: var(--font-mono); font-size: var(--text-lead); margin: 0; }

.summary {
  display: flex;
  gap: var(--gap-xl);
  flex-wrap: wrap;
  margin-bottom: var(--gap-l);
  padding: var(--gap-m) var(--gap-l);
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: 8px;
}
.fact { display: flex; flex-direction: column; }
.fact .name { font-size: var(--text-caption); color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.fact .value { font-family: var(--font-mono); font-size: var(--text-lead); }

/* A meter's own row: its identity, then what is known about it, across the
   whole table. */
.readings tr.device td {
  background: var(--page);
  white-space: normal;
  padding-top: var(--gap-m);
}
.readings .identity { font-weight: 600; margin-right: var(--gap-m); }
.readings .facts { color: var(--ink-quiet); }
.readings .problem { color: var(--bad); margin-left: var(--gap-m); }

/* A value that has moved since the first reading: the arrow and the colour say
   which way, and the number says how far. */
.readings .change { min-width: 8rem; }
.readings .rises { color: var(--good); font-family: var(--font-mono); font-weight: 600; }
.readings .falls { color: var(--falls); font-family: var(--font-mono); font-weight: 600; }

#unresolved ul { margin: 0; padding-left: var(--gap-l); font-size: var(--text-small); }

.wire { margin-top: var(--gap-l); }
.wire summary { cursor: pointer; color: var(--ink-quiet); font-size: var(--text-small); }
.wire pre {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: 8px;
  padding: var(--gap-m);
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  max-height: 20rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

@media screen and (max-width: 640px) {
  body { padding: var(--gap-l) var(--gap-m); }
  .narrow, .minutes { width: 100%; }
  .summary { gap: var(--gap-l); }
}
