/*
 * Colour carries WHO SPOKE and nothing else. Severity gets one column of its own.
 *
 * A timeline that colours by source and by severity at once becomes a rainbow, and a reader
 * scanning it stops being able to tell which dimension a colour meant. Source is the thing being
 * scanned for here — "what did the card do while the SM-DP+ was doing that" — so source gets the
 * colour.
 */
:root {
  --ground: #f5f6f7;
  --surface: #fff;
  --surface-2: #eceff1;
  --ink: #151c21;
  --ink-2: #46545d;
  --ink-3: #74838d;
  --rule: #d7dde1;
  --accent: #0d6f76;
  --accent-ink: #fff;
  --ok: #2f6d47;
  --warn: #8a6410;
  --bad: #a8431c;

  --src-sim: #0d6f76;
  --src-smdpplus: #6a3fa0;
  --src-smsr: #1f5fa8;
  --src-eim: #8a6410;
  --src-ipa: #2f6d47;
  --src-other: #74838d;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0f1519;
    --surface: #161e23;
    --surface-2: #1d272d;
    --ink: #e6ebee;
    --ink-2: #b1bdc5;
    
    --ink-3: #84939d;
    --rule: #2a353c;
    --accent: #4fb3ba;
    --accent-ink: #0b1418;
    --ok: #6fc08d;
    --warn: #d3aa4e;
    --bad: #e08b64;

    --src-sim: #4fb3ba;
    --src-smdpplus: #b492e0;
    --src-smsr: #7fb0e8;
    --src-eim: #d3aa4e;
    --src-ipa: #6fc08d;
    --src-other: #84939d;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.mono, code, input.mono, td.mono {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

/* ---- masthead ---- */
.mast {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 32px;
  align-items: flex-end;
  justify-content: space-between;
  padding: 18px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}
.mast h1 { margin: 0; font-size: 19px; letter-spacing: -0.01em; }
.sub { margin: 4px 0 0; color: var(--ink-3); font-size: 13px; max-width: 62ch; }

.token { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; position: relative; }
.token label, .token .or { font-size: 12px; color: var(--ink-3); }
.token input { width: 260px; }

.howto summary {
  list-style: none; cursor: pointer;
  width: 22px; height: 22px; line-height: 20px; text-align: center;
  border: 1px solid var(--rule); border-radius: 50%;
  font-size: 12px; color: var(--ink-3);
}
.howto summary::-webkit-details-marker { display: none; }
.howto[open] summary { border-color: var(--accent); color: var(--accent); }
.howto-body {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 10;
  width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 4px;
  box-shadow: 0 6px 20px rgb(0 0 0 / .12);
  font-size: 13px;
}
.howto-body p { margin: 0 0 6px; }
.howto-body ol { margin: 0 0 8px; padding-left: 18px; }
.howto-body li { margin-bottom: 4px; }

/* ---- layout: three panes, because the three questions are different ---- */
main {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) minmax(280px, 1.2fr) minmax(380px, 2fr);
  gap: 1px;
  background: var(--rule);
  min-height: calc(100vh - 78px);
}
@media (max-width: 1000px) { main { grid-template-columns: 1fr; } }

.pane { background: var(--surface); padding: 16px 18px; min-width: 0; }
.pane-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.pane h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3); }

/* ---- controls ---- */
button {
  font: inherit; font-size: 13px;
  padding: 6px 12px;
  border: 1px solid var(--rule);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 4px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
/* Scrapping a card cannot be undone and its EID is never issued again, so the control says so
   before it is pressed rather than only in the confirmation beside it. */
button.danger { color: var(--bad, #b42318); }
button.danger:hover:not(:disabled) { border-color: var(--bad, #b42318); }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

input, select {
  font: inherit; font-size: 13px;
  padding: 6px 9px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  min-width: 0;
}

.field { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.field input { flex: 1; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }

/* ---- pills ---- */
.pill {
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 3px; white-space: nowrap;
}
.pill.unknown { background: var(--surface-2); color: var(--ink-3); }
.pill.ok      { background: var(--surface-2); color: var(--ok); }
.pill.bad     { background: var(--surface-2); color: var(--bad); }
.pill.idle    { background: var(--surface-2); color: var(--ink-3); }
.pill.live    { background: var(--surface-2); color: var(--ok); }
.pill.paused  { background: var(--surface-2); color: var(--warn); }

/* ---- card list ---- */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px;
}
.list li:hover { background: var(--surface-2); }
.list li.selected { background: var(--surface-2); border-color: var(--accent); }
.list li.empty, .empty { color: var(--ink-3); cursor: default; font-style: italic; font-family: inherit; font-size: 13px; }

/* ---- card facts ---- */
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 16px; }
.facts dt { color: var(--ink-3); font-size: 12px; }
.facts dd { margin: 0; font-size: 13px; overflow-wrap: anywhere; }

.send label { display: block; font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.hints { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.hint { font-size: 11.5px; padding: 3px 8px; }
.error { color: var(--bad); font-size: 12.5px; margin: 8px 0 0; }
.note { color: var(--ink-3); font-size: 12px; margin: 0 0 12px; }

/* ---- timeline: a table, not a log ---- */
.scroll { overflow-x: auto; border: 1px solid var(--rule); border-radius: 4px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th {
  text-align: left; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 600;
  padding: 8px 10px; background: var(--surface-2);
  border-bottom: 1px solid var(--rule); white-space: nowrap;
}
td { padding: 7px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; color: var(--ink-3); text-align: right; white-space: nowrap; }

/* Source is the only thing colour means here. */
.who { font-weight: 600; font-size: 12px; white-space: nowrap; }
.who[data-source="SIM"]       { color: var(--src-sim); }
.who[data-source="SMDPPLUS"]  { color: var(--src-smdpplus); }
.who[data-source="SMSR"]      { color: var(--src-smsr); }
.who[data-source="EIM"]       { color: var(--src-eim); }
.who[data-source="IPA"]       { color: var(--src-ipa); }
.who:not([data-source="SIM"]):not([data-source="SMDPPLUS"]):not([data-source="SMSR"]):not([data-source="EIM"]):not([data-source="IPA"]) { color: var(--src-other); }

.dir { color: var(--ink-3); font-size: 11px; white-space: nowrap; }

/* Hex behind a disclosure: an undifferentiated wall of it is what makes these pages unreadable. */
details.hex { margin-top: 4px; }
details.hex summary {
  cursor: pointer; color: var(--ink-3); font-size: 11.5px; list-style: none;
}
details.hex summary::-webkit-details-marker { display: none; }
details.hex summary::before { content: "▸ "; }
details.hex[open] summary::before { content: "▾ "; }
details.hex pre {
  margin: 6px 0 0;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: 3px;
  font-size: 11.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.hex-actions { display: flex; gap: 8px; margin-top: 6px; }
.hex-actions button { font-size: 11px; padding: 2px 8px; }

.empty-row td { color: var(--ink-3); font-style: italic; }
