/* FieldLink's shared look: the single-line diagram.
   Drawing-sheet ground, ink hairlines, square corners. Colour is potential
   and carries state only: live (green), act (blue: a person must do
   something), warn (amber), fail (red), dead (grey). */

:root {
  color-scheme: light dark;
  --sheet: #fbfbf8; --panel: #f0f0ea; --field: #ffffff;
  --ink: #14181c; --ink-2: #4a5259; --rule: #c9ccc8; --rule-2: #8d928e;
  --live: #2e7d32; --act: #1e4fa3; --warn: #8a5a00; --fail: #b3261e; --dead: #a9ada8;
  --live-bg: #e6f2e6; --act-bg: #e4ebf7; --warn-bg: #fbf0d0; --fail-bg: #fbe6e3;
  --on-solid: #fbfbf8;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --t-xs: .75rem; --t-sm: .8125rem; --t-md: .9375rem; --t-lg: 1.0625rem; --t-xl: 1.25rem; --t-2xl: 1.5rem; --t-3xl: 1.875rem;
  --bar-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --sheet: #101418; --panel: #171c22; --field: #0b0e11;
    --ink: #e8eae6; --ink-2: #a3abb1; --rule: #2f363d; --rule-2: #5a626a;
    --live: #63c56f; --act: #86adf2; --warn: #e3b341; --fail: #f28b82; --dead: #4a5158;
    --live-bg: #14301a; --act-bg: #16264a; --warn-bg: #3a2d08; --fail-bg: #3d1714;
    --on-solid: #101418;
  }
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; background: var(--sheet); color: var(--ink);
  font: var(--t-md)/1.45 "Segoe UI", system-ui, sans-serif; font-variant-numeric: tabular-nums;
  scrollbar-color: var(--rule-2) var(--sheet); }
::selection { background: var(--ink); color: var(--sheet); }
:focus-visible { outline: 2px solid var(--act); outline-offset: 2px; }
a { color: var(--act); text-underline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--t-3xl); font-weight: 600; line-height: 1.15; text-wrap: balance; }
h2 { font-size: var(--t-xl); font-weight: 600; line-height: 1.25; }
h3 { font-size: var(--t-lg); font-weight: 600; }
code, .num { font-family: "Cascadia Mono", Consolas, monospace; font-size: .92em; }
.muted { color: var(--ink-2); }
.small { font-size: var(--t-sm); }
[hidden] { display: none !important; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: square; }

/* Title block: the top bar, a row of ruled cells. */
.bar { display: flex; align-items: stretch; min-height: var(--bar-h); background: var(--sheet);
  border-bottom: 2px solid var(--ink); position: sticky; top: 0; z-index: 5; }
.bar > * { display: flex; align-items: center; gap: var(--s2); padding: 0 var(--s4); border-right: 1px solid var(--ink); }
.bar > :last-child { border-right: 0; }
.bar .grow { flex: 1; min-width: 0; }
.brand { font-size: var(--t-xl); font-weight: 700; letter-spacing: .01em; color: var(--ink); text-decoration: none; }
.brand .icon { width: 26px; height: 26px; stroke-width: 2; }
.cell { flex-direction: column; align-items: flex-start !important; justify-content: center; gap: 0 !important; white-space: nowrap; }
.cell small { font-size: var(--t-xs); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.bar form { margin: 0; }
.bar nav { gap: 0; padding: 0; }
.bar nav a { display: flex; align-items: center; height: 100%; padding: 0 var(--s3); color: var(--ink); text-decoration: none;
  border-right: 1px solid var(--rule); }
.bar nav a:last-child { border-right: 0; }
.bar nav a:hover { background: var(--panel); }
.bar nav a[aria-current] { background: var(--ink); color: var(--on-solid); }

main { padding: var(--s5); max-width: 1500px; margin: 0 auto; }
main.narrow { max-width: 460px; padding-top: var(--s6); }
.stack > * + * { margin-top: var(--s4); }
.lede { color: var(--ink-2); margin-top: var(--s1); }
.group { font-size: var(--t-xs); font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2);
  border-bottom: 1px solid var(--ink); padding: var(--s5) 0 var(--s2); margin: 0; }

/* Controls */
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 38px;
  padding: 0 var(--s4); border: 1.5px solid var(--ink); border-radius: 0; background: transparent; color: var(--ink);
  font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color .15s, color .15s, border-color .15s; }
button:hover, .btn:hover { background: var(--panel); }
button:active, .btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: var(--on-solid); }
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn-act { background: var(--act); border-color: var(--act); color: var(--on-solid); }
.btn-act:hover { background: var(--ink); border-color: var(--ink); }
.btn-danger { border-color: var(--fail); color: var(--fail); }
.btn-danger:hover { background: var(--fail); color: var(--on-solid); }
.btn-quiet { border-color: transparent; color: var(--ink-2); padding: 0 var(--s2); }
.btn-quiet:hover { color: var(--ink); background: var(--panel); }
.btn-icon { min-height: 28px; width: 28px; padding: 0; }
.btn-small { min-height: 30px; padding: 0 var(--s3); font-size: var(--t-sm); }
button:disabled, .btn[aria-disabled=true] { border-color: var(--rule); color: var(--rule-2); background: transparent; cursor: not-allowed; }
button[aria-pressed=true] { background: var(--ink); color: var(--on-solid); }

label { display: block; font-weight: 500; }
label .hint { display: block; font-weight: 400; color: var(--ink-2); font-size: var(--t-sm); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--field); border: 1.5px solid var(--rule-2);
  border-radius: 0; min-height: 38px; padding: 0 var(--s3); caret-color: var(--act); }
textarea { padding: var(--s2) var(--s3); }
input:hover, select:hover, textarea:hover { border-color: var(--ink); }
input::placeholder { color: var(--ink-2); }
label > input, label > select, label > textarea { display: block; width: 100%; margin-top: var(--s1); }
input[type=checkbox], input[type=radio] { min-height: 0; width: 16px; height: 16px; padding: 0; accent-color: var(--ink); }
.check { display: inline-flex; align-items: center; gap: var(--s2); font-weight: 400; }
.inline { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
details > summary { cursor: pointer; color: var(--ink-2); }
details[open] > summary { margin-bottom: var(--s2); }

/* Messages: a full border and a tint, with the state named in words. */
.note { border: 1px solid var(--rule-2); background: var(--panel); padding: var(--s3) var(--s4); }
.note.is-fail { border-color: var(--fail); background: var(--fail-bg); }
.note.is-warn { border-color: var(--warn); background: var(--warn-bg); }
.note.is-act { border-color: var(--act); background: var(--act-bg); }
.note.is-live { border-color: var(--live); background: var(--live-bg); }
.tag { display: inline-flex; align-items: center; gap: var(--s1); font-size: var(--t-sm); padding: 1px var(--s2);
  border: 1px solid var(--rule-2); background: var(--panel); white-space: nowrap; }
.tag.is-warn { border-color: var(--warn); background: var(--warn-bg); }
.tag.is-fail { border-color: var(--fail); background: var(--fail-bg); }
.tag.is-live { border-color: var(--live); background: var(--live-bg); }
.tag.is-act { border-color: var(--act); background: var(--act-bg); }
.state-live { color: var(--live); } .state-act { color: var(--act); } .state-warn { color: var(--warn); } .state-fail { color: var(--fail); }

/* Sections and tables */
.sheet { border: 1px solid var(--ink); padding: var(--s4) var(--s5) var(--s5); background: var(--sheet); }
.sheet + .sheet { margin-top: var(--s5); }
.sheet > h2 { margin-bottom: var(--s3); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: var(--t-xs); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2);
  border-bottom: 1px solid var(--ink); padding: var(--s2) var(--s3) var(--s2) 0; white-space: nowrap; }
td { border-bottom: 1px solid var(--rule); padding: var(--s2) var(--s3) var(--s2) 0; vertical-align: top; }
tr:last-child > td { border-bottom: 0; }
.empty { border: 1px dashed var(--rule-2); padding: var(--s5); color: var(--ink-2); text-align: center; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--s1) var(--s4); margin: 0; }
dl.facts dt { color: var(--ink-2); } dl.facts dd { margin: 0; }
pre.log { margin: 0; padding: var(--s3); background: var(--field); border: 1px solid var(--rule-2); overflow: auto;
  font: var(--t-sm)/1.5 "Cascadia Mono", Consolas, monospace; max-height: 70vh; }

/* The line: this laptop, the relay, the switch at the machine, the machine.
   .is-live closed and green · .is-open switch open, a person must close it ·
   .is-asking open and dashed · .is-dead offline · .is-fail broken ·
   .is-connecting with .step-1..3 closing segment by segment. */
.line { display: grid; grid-template-columns: 18px minmax(24px, 1fr) 14px minmax(24px, 1fr) 40px 22px; align-items: center;
  height: 28px; color: var(--dead); min-width: 200px; }
.line i { display: block; }
.ln-node { width: 18px; height: 18px; border: 2px solid var(--ink); border-radius: 50%; }
.ln-relay { width: 14px; height: 14px; border: 2px solid var(--ink); }
.ln-machine { width: 22px; height: 22px; border: 2px solid var(--ink); transition: background-color .2s; }
.ln-wire { height: 0; border-top: 3px solid currentColor; transition: border-color .2s; }
.ln-switch { position: relative; height: 28px; }
.ln-switch b { position: absolute; left: 0; top: calc(50% - 1.5px); width: 40px; border-top: 3px solid currentColor; transform-origin: left center;
  transition: transform .22s cubic-bezier(.2, .9, .3, 1), border-color .2s; }
.line.is-live { color: var(--live); } .line.is-live .ln-machine { background: var(--ink); }
.line.is-open, .line.is-asking { color: var(--act); }
.line.is-open .ln-switch b, .line.is-asking .ln-switch b, .line.is-dead .ln-switch b, .line.is-fail .ln-switch b { width: 30px; transform: rotate(-28deg); }
.line.is-asking .ln-wire, .line.is-asking .ln-switch b { border-top-style: dashed; }
.line.is-dead .ln-node, .line.is-dead .ln-relay, .line.is-dead .ln-machine { border-color: var(--dead); }
.line.is-fail { color: var(--fail); }
.line.is-connecting { color: var(--dead); }
.line.is-connecting .ln-switch b { width: 30px; transform: rotate(-28deg); }
.line.is-connecting.step-1 .w1, .line.is-connecting.step-2 .w1, .line.is-connecting.step-3 .w1,
.line.is-connecting.step-2 .w2, .line.is-connecting.step-3 .w2 { border-color: var(--live); }
.line.is-connecting.step-3 .ln-switch b { width: 40px; transform: none; border-color: var(--live); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
