/* Boat Monitor. Colours as variables, redefined for dark mode. */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1e21;
  --muted: #6b7280;
  --line: #e3e5e8;
  --accent: #1f6feb;
  --good: #1a9e4b;
  --warn: #e08a00;
  --bad: #d93025;
  --event: #1f6feb;
  /* Chart series: the first three categorical slots, validated together */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --sat-shade: rgba(98, 80, 214, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --card: #1b1e24;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --line: #2c3038;
    --accent: #5b9dff;
    --good: #3fc06a;
    --warn: #f0a52a;
    --bad: #f0605a;
    --event: #5b9dff;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --sat-shade: rgba(144, 133, 233, .12);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* The header: one bar of what matters at a glance, then the views */
header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1100;   /* above the map's panes and controls (1000) */
}
.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 10px 16px 6px;
}
header h1 { font-size: 17px; margin: 0; }
header select, header input, header button {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
}
header button { cursor: pointer; }
.status { display: contents; }   /* on a phone, its own row */
.bar-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-variant-numeric: tabular-nums; }
.fact { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.fact .bars { width: 18px; height: 13px; }
.fact.warning { color: var(--warn); }
.fact.error { color: var(--bad); }
#units { margin-left: auto; }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.menu summary::-webkit-details-marker { display: none; }
.menu[open] summary { background: var(--bg); }
#token-form {
  position: absolute; right: 0; top: 32px; z-index: 1;
  display: flex; flex-direction: column; gap: 6px; width: 280px;
  padding: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .15);
}
#token-form label { font-size: 12px; color: var(--muted); }

.live { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.live.fresh .dot { background: var(--good); }
.live.late .dot { background: var(--warn); }
.live.lost .dot { background: var(--bad); }

nav.views { display: flex; gap: 2px; padding: 0 12px; }
nav.views a {
  color: var(--muted); text-decoration: none; font-weight: 500; padding: 6px 10px 8px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
nav.views a.on { color: var(--text); border-bottom-color: var(--accent); }
nav.views a:hover { color: var(--text); }

#error {
  margin: 12px 16px 0;
  padding: 8px 12px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--bad) 14%, var(--card));
  color: var(--text);
}

main { padding: 16px; }
/* Each view is a grid of two columns, the map's row three; on a phone, one */
.view { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.view[hidden] { display: none; }
#view-voyage { grid-template-columns: 2fr 1fr; }
.map-card, .now-card { grid-row: 1; }
#view-voyage #setup, #view-voyage #commands { grid-column: auto; }
@media (max-width: 900px) {
  .view, #view-voyage { grid-template-columns: 1fr; }
  .map-card, .now-card { grid-row: auto; }
}
/* On a phone the header is two tight rows and the views are tabs along the bottom, under the thumb */
@media (max-width: 600px) {
  .bar { gap: 6px 10px; padding: 8px 12px 6px; }
  header h1 { display: none; }
  #boat { flex: 1 1 auto; min-width: 0; }
  .status { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; flex-basis: 100%; order: 3; }
  .bar-facts { gap: 4px 12px; }
  nav.views {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100;
    background: var(--card); border-top: 1px solid var(--line);
    padding: 0 0 env(safe-area-inset-bottom); gap: 0;
  }
  nav.views a { flex: 1; text-align: center; padding: 11px 0 12px; margin: 0; border-bottom: none; border-top: 2px solid transparent; }
  nav.views a.on { border-top-color: var(--accent); }
  main { padding: 12px 12px calc(64px + env(safe-area-inset-bottom)); }
  .view { gap: 12px; }
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  min-width: 0;
}
.card h2 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin: 0 0 8px;
}
.wide { grid-column: 1 / -1; }
.muted { color: var(--muted); }
.note { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
h2 .when { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 6px; }

/* Systems: one tile per part of the boat. Colour only flags: orange for a
   warning in the newest report, red for an error, as on the app's rail. */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile { border-left: 3px solid var(--line); padding: 2px 0 2px 10px; min-width: 0; }
.tile-label { font-size: 12px; color: var(--muted); }
.tile-value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile-detail { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); }
.tile.warning { border-left-color: var(--warn); }
.tile.warning .tile-value { color: var(--warn); }
.tile.error { border-left-color: var(--bad); }
.tile.error .tile-value { color: var(--bad); }
.with-bars { display: inline-flex; align-items: center; gap: 6px; }
.bars { width: 22px; height: 16px; }
.bars .on { fill: currentColor; }
.bars .off { fill: var(--line); }
.spark { width: 120px; height: 30px; border: 1px solid var(--line); margin: 3px 0 1px; }
.spark path { fill: none; stroke: var(--text); stroke-width: 1; }

/* Now: the dial and its numbers */
.headline { font-size: 18px; font-weight: 600; margin: 0 0 8px; }
.now { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.dial { width: 240px; max-width: 100%; flex: none; }
.stats { flex: 1 1 280px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 16px; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--muted); }
.heel { position: relative; height: 8px; margin: 4px 0; background: var(--dial-track); border-radius: 4px; }
.heel-mid { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--dial-ring); }
.heel-band { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: var(--dial-tick); }
.heel-avg { position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: var(--dial-hull); }

/* The dial's palette is the app's (DialPalette), darkened for dark mode */
:root {
  --dial-face: #f4f6f8; --dial-ring: #aeb7c0; --dial-tick: #8a95a1; --dial-letter: #6b7684;
  --dial-north: #3a4654; --dial-hull: #1b2430; --dial-sail: #e9d8a6; --dial-world: #1d5fb4;
  --dial-target: #d9731f; --dial-track: #e8ecf0; --dial-edge: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --dial-face: #232830; --dial-ring: #59626d; --dial-tick: #7c8692; --dial-letter: #9aa3ad;
    --dial-north: #d5dbe1; --dial-hull: #dfe5ec; --dial-world: #5b9dff; --dial-track: #2c3038;
    --dial-edge: #111317;
  }
}
.dial-face { fill: var(--dial-face); stroke: var(--dial-ring); stroke-width: 1.5; }
.dial-tick { stroke: var(--dial-tick); }
.dial-letter { fill: var(--dial-letter); font-size: 13px; }
.dial-letter.north { fill: var(--dial-north); font-weight: 700; font-size: 14.5px; }
.dial-band { fill: none; stroke: var(--dial-hull); stroke-width: 7; stroke-linecap: round; }
.dial-band-edge { fill: none; stroke: var(--dial-edge); stroke-width: 9; stroke-linecap: round; }
.dial-wind-band { fill: none; stroke: var(--dial-world); stroke-opacity: .35; stroke-width: 7; stroke-linecap: round; }
.dial-world { fill: var(--dial-world); stroke: var(--dial-world); stroke-width: 3; stroke-linejoin: round; }
.dial-edge { fill: var(--dial-edge); stroke: var(--dial-edge); stroke-width: 5; stroke-linejoin: round; }
.chevron { fill: none; stroke-linecap: round; }
.dial-world.chevron { stroke-width: 2.5; }
.dial-edge.chevron { stroke-width: 4.5; }
.dial-target { fill: var(--dial-target); stroke: var(--dial-edge); stroke-width: 1; }
.dial-hull { fill: var(--dial-hull); }
.dial-rudder { stroke: var(--dial-hull); stroke-width: 4; stroke-linecap: round; }
.dial-boom { stroke: var(--dial-sail); stroke-width: 4; stroke-linecap: round; }

/* Tables of rows: setup, readings */
table.rows { width: 100%; border-collapse: collapse; }
.rows th, .rows td { text-align: left; vertical-align: top; padding: 5px 8px 5px 0; border-bottom: 1px solid var(--line); }
.rows tr:last-child th, .rows tr:last-child td { border-bottom: none; }
.rows th { font-weight: 500; white-space: nowrap; width: 1%; padding-right: 14px; }

/* Alerts: a dot (red error, orange warning, blue event), the sentence, when */
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; margin-bottom: 6px; }
.segmented button {
  font: inherit; font-size: 12px; color: var(--muted); background: transparent;
  border: none; border-right: 1px solid var(--line); padding: 3px 10px; cursor: pointer;
}
.segmented button:last-child { border-right: none; }
.segmented button.on { background: var(--bg); color: var(--text); font-weight: 600; }
.alerts { list-style: none; margin: 0; padding: 0; max-height: 560px; overflow-y: auto; }
.alerts li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.alerts li:last-child { border-bottom: none; }
.alert { display: flex; gap: 8px; align-items: baseline; }
.sev-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; transform: translateY(-1px); }
.alert.sev-error .sev-dot { background: var(--bad); }
.alert.sev-warning .sev-dot { background: var(--warn); }
.alert.sev-event .sev-dot { background: var(--event); }
.alert-when { font-size: 12px; color: var(--muted); }

/* Commands */
.scroll { max-height: 560px; overflow: auto; }
.pill { font-size: 11px; padding: 1px 7px; border-radius: 9px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.pill.done { color: var(--good); }
.pill.sent { color: var(--warn); }
.pill.queued { color: var(--accent); }

/* Charts: one measure each, a shared time axis */
.charts-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 8px; }
.charts-head h2 { margin: 0; }
.charts-head .segmented { margin: 0; }
.sat-note { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.sat-note i { width: 14px; height: 10px; background: var(--sat-shade); border: 1px solid var(--line); }
.link-button { font: inherit; font-size: 12px; color: var(--accent); background: none; border: none; cursor: pointer; padding: 0; margin-left: auto; }
.charts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 14px 22px; }
@media (max-width: 520px) { .charts-grid { grid-template-columns: 1fr; } }
.chart { min-width: 0; }
.chart-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; font-size: 12px; min-height: 18px; }
.chart-title { font-weight: 600; }
.readout { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text); }
.legend { display: inline-flex; gap: 10px; color: var(--muted); }
.key { display: inline-flex; align-items: center; gap: 4px; }
.key i { width: 12px; height: 2px; border-radius: 1px; }
.chart-box { position: relative; height: 130px; }
.chart-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.chart-box canvas.over { cursor: crosshair; touch-action: pan-y; }

/* Map */
.map-card { padding: 0; overflow: hidden; display: flex; }
#map { flex: 1; min-height: 560px; background: var(--bg); }
@media (max-width: 900px) { #map { min-height: 380px; } }
.map-missing { padding: 40px 16px; text-align: center; color: var(--muted); margin: 0; }
.map-follow {
  font: inherit; font-size: 12px; font-weight: 600; background: var(--accent); color: #fff; cursor: pointer;
  border: 2px solid rgba(0, 0, 0, .2); border-radius: 999px; padding: 5px 11px; background-clip: padding-box;
}
.map-follow[hidden] { display: none; }
.boat-icon { background: none; border: none; }
.boat-hull { fill: #1b2430; stroke: #fff; stroke-width: 1.5; }
.boat-boom { stroke: #e9d8a6; stroke-width: 2.5; stroke-linecap: round; }
.wind-edge { stroke: #fff; stroke-width: 5; stroke-linecap: round; }
.wind-shaft { stroke: #1d5fb4; stroke-width: 2.5; stroke-linecap: round; }
.wind-head { fill: #1d5fb4; stroke: #fff; stroke-width: 1.2; stroke-linejoin: round; }
.wind-turn[hidden] { display: none; }
/* The route's waypoint pins (RouteLayer): numbered, the target orange, grey while the boat hasn't the route */
.wp-pin { background: #007aff; color: #fff; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.4);
          display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.wp-pin.target { background: #ff9500; }
.wp-pin.grey { background: #8e8e93; }
.wp-pin.hold span::after { content: "⚓"; font-size: 8px; margin-left: 1px; }
/* Currents (CurrentsLayer): an arrow where the water runs, its speed under it; the boat's drift in orange */
.current { background: none; border: none; color: #32ade6; display: flex; flex-direction: column; align-items: center; }
.current.drift { color: #ff9500; }
.current i { display: block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.current b { font-size: 11px; color: #fff; background: rgba(50, 173, 230, .85); border-radius: 4px; padding: 0 4px; margin-top: 2px; white-space: nowrap; }
.current.drift b { background: rgba(255, 149, 0, .85); }
#alerts .alerts { max-height: 470px; }
.boat-alerts { max-height: none; margin-bottom: 8px; }
.boat-alert.ongoing .sev-dot { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 25%, transparent); }
.boat-alert.over .sev-dot { background: var(--muted); }
.boat-alert.over { color: var(--muted); }
.alert-title { font-weight: 600; }
#alerts h3 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 8px 0 6px; }

/* Live feed */
#feed { display: flex; flex-direction: column; max-height: 600px; }
.feed-list { list-style: none; margin: 4px 0 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.feed-row { display: flex; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.feed-row.has-warning { box-shadow: inset 3px 0 0 var(--warn); padding-left: 8px; }
.feed-row.has-error { box-shadow: inset 3px 0 0 var(--bad); padding-left: 8px; }
.feed-row.arrived { animation: arrive .5s ease-out; }
@keyframes arrive {
  from { opacity: 0; transform: translateY(-6px); background: color-mix(in srgb, var(--accent) 12%, transparent); }
  to { opacity: 1; transform: none; background: transparent; }
}
.feed-net { width: 38px; flex: none; display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: 10px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.feed-pct { font-weight: 500; letter-spacing: 0; }
.feed-arrow { font-size: 18px; color: var(--accent); }
.feed-body { flex: 1; min-width: 0; }
.feed-head { display: flex; align-items: baseline; gap: 8px; }
.feed-title { font-weight: 600; }
.feed-head .rel { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip { font-size: 12px; padding: 1px 7px; border-radius: 10px; background: var(--bg); color: var(--text); white-space: nowrap; }
.chip.warn { color: var(--warn); }
.chip.muted-chip { color: var(--muted); background: transparent; border: 1px solid var(--line); }
.chip.cmd-sent { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--card)); }
.chip.cmd-done { color: var(--good); background: color-mix(in srgb, var(--good) 12%, var(--card)); }
.feed-items { list-style: none; margin: 5px 0 0; padding: 0; font-size: 13px; }
.feed-item { display: flex; gap: 6px; align-items: baseline; }
.feed-item.sev-error .sev-dot { background: var(--bad); }
.feed-item.sev-warning .sev-dot { background: var(--warn); }
.feed-item.sev-event .sev-dot { background: var(--event); }
.feed-ongoing { color: var(--muted); }
.feed-ongoing .sev-dot { opacity: .6; }
.feed-gap { text-align: center; font-size: 12px; color: var(--muted); padding: 6px 0; border-bottom: 1px dashed var(--line); }
.feed-push .feed-title { color: var(--accent); }
.rows a { color: var(--accent); }

/* The link report */
#link-report h3 { font-size: 14px; font-weight: 600; margin: 16px 0 6px; }
#link-report h3 .when { font-weight: 400; }
.insights { margin: 12px 0 0; padding-left: 20px; }
.insights li { margin: 4px 0; }
/* The packet report (conversation.js): the boat's lines on the left, the server's on the right, each a box in its kind's colour */
.conversation { list-style: none; margin: 0 0 4px; padding: 0; max-height: 600px; overflow-y: auto; font-size: 13px; }
.convo-heads { display: flex; justify-content: space-between; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 0 2px 6px; }
.convo-heads span { display: inline-flex; align-items: center; gap: 5px; }
.convo-icon { width: 22px; height: 22px; }
.convo-icon .sail { fill: var(--text); } .convo-icon .jib { fill: var(--muted); } .convo-icon .hull { fill: var(--series-1); }
.server-box { fill: var(--card); stroke: var(--muted); stroke-width: 1.4; }
.server-led { fill: var(--good); }
.convo { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; align-items: baseline; padding: 2px 0; --kind: var(--series-1); }
.convo-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.convo.up .convo-line { grid-column: 1; }
.convo.down .convo-line { grid-column: 2; justify-content: flex-end; }
.convo.up .convo-main { border-left: 3px solid var(--kind); border-radius: 3px 8px 8px 3px; }
.convo.down .convo-main { text-align: right; border-right: 3px solid var(--kind); border-radius: 8px 3px 3px 8px; }
.convo-via { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); flex: none; }
.convo-via .bars { width: 16px; height: 12px; color: var(--muted); }
.sat-icon { width: 22px; height: 22px; }
.sat-body { fill: var(--muted); } .sat-panel { fill: var(--series-1); } .sat-beam { fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; }
.convo-via.lost .convo-arrow { color: var(--bad); font-weight: 700; }
.convo-main { display: inline-block; box-sizing: border-box; flex: none; min-width: var(--w, 0); min-height: var(--h, 0); max-width: 100%;
              padding: 3px 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
              background: color-mix(in srgb, var(--kind) 12%, var(--card)); }
.convo-title { font-weight: 500; }
.convo-item { font-size: 12px; opacity: .85; }
.convo-arrow { color: var(--muted); font-weight: 600; }
.convo .pill { margin-left: 6px; }
.convo-idle { text-align: center; color: var(--muted); font-size: 12px; padding: 1px 0; }
.convo-note { padding: 4px 0; font-size: 12px; }
.convo.kind-reply, .convo.kind-position_reply, .convo.kind-pull_reply, .convo.kind-burst { --kind: var(--good); }
.convo.kind-push { --kind: var(--warn); }
.convo.kind-start_over { --kind: var(--bad); }
.convo.kind-key, .convo.kind-key_reply, .convo.kind-registration, .convo.kind-registered { --kind: #8e5bd8; }
.convo.kind-position { --kind: var(--series-3); }
.convo.kind-pull { --kind: #1a9e9e; }
.pill.kind-gap, .pill.kind-held { color: var(--warn); }
.pill.kind-repeat, .pill.kind-checkin { color: var(--good); }
.pill.kind-command, .pill.kind-push { color: var(--accent); }

/* Cycles */
.cycle { padding: 6px 0; border-bottom: 1px solid var(--line); }
.cycle:last-child { border-bottom: none; }
.cycle summary { list-style: none; cursor: pointer; }
.cycle summary::-webkit-details-marker { display: none; }
.cycle-head { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.cycle-head .num { font-weight: 600; }
.cycle-head::before { content: "▸"; color: var(--muted); font-size: 11px; width: 10px; }
.cycle[open] .cycle-head::before { content: "▾"; }
.cycle-head .cycle-bar { flex: 1 1 160px; margin: 0; min-width: 120px; }
.cycle-body { padding: 8px 0 4px 22px; }
.cycle-bar { display: flex; height: 12px; border-radius: 4px; overflow: hidden; background: var(--bg); margin: 4px 0 8px; }
.cycle-bar span { display: block; height: 100%; min-width: 1px; }
.cycle-bar .seg-reconnect { background: var(--warn); }
.cycle-bar .seg-reply { background: var(--accent); }
.cycle-bar .seg-listen, .cycle-bar .seg-connected { background: var(--good); opacity: .7; }
.cycle-bar .seg-gps { background: #8e5bd8; }
.cycle-bar .seg-idle { background: var(--line); }
.cycle-bar .seg-wait { background: var(--bad); opacity: .5; }
.cycle-bar .seg-unknown { background: var(--line); }
.cycle-bar .estimated { background-image: repeating-linear-gradient(45deg, transparent 0 4px, rgba(255,255,255,.35) 4px 8px); }
.cycle-key { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.cycle-key i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; margin-right: 4px; }
.cycle-events { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.cycle-events li { display: flex; gap: 10px; padding: 2px 0; }
.cycle-events .num { min-width: 7ch; }

/* The packet viewer */
.packet { width: min(1100px, 96vw); max-height: 92vh; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); padding: 14px 18px; }
/* The dump and legend stay put; the field table takes what's left and is the
   only thing that scrolls, so the dialog itself never does */
.packet[open] { display: flex; flex-direction: column; }
#packet-body { display: flex; flex-direction: column; min-height: 0; }
#packet-body > :not(.scroll) { flex: none; }
#packet-body .scroll { flex: 1 1 auto; min-height: 0; max-height: none; }
.packet-fields thead th { position: sticky; top: 0; background: var(--card); z-index: 1; }
.packet::backdrop { background: rgba(0, 0, 0, .45); }
.packet-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.packet-head { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; }
.hexdump { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 8px; overflow-x: auto; }
.hexrow { white-space: nowrap; }
.hexoff { color: var(--muted); margin-right: 12px; }
.hexbyte { padding: 1px 2px; border-radius: 3px; }
.hexbyte.gap { margin-right: 8px; }
.hexbyte.hi, .packet-field.hi { font-weight: 700; }
.hexbyte.hi { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.packet-field.hi td { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.hexbyte.hover { outline: 2px solid var(--accent); }
.hexbyte { cursor: pointer; }
.packet-field.flash td { animation: field-flash 1.2s ease-out; }
@keyframes field-flash { from { background: color-mix(in srgb, var(--accent) 35%, transparent); } to { background: transparent; } }
.packet-field.hover td { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.packet-fields th { color: var(--muted); font-weight: 500; }
.packet-fields td { font-size: 13px; }
/* A value can be a long run of hex (a key, a tag): break it anywhere
   rather than let it push the meaning off the side of the dialog */
.packet-fields td.wrap { overflow-wrap: anywhere; min-width: 16ch; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }
.small { font-size: 11px; }
.cycle-key .hi { font-weight: 700; color: var(--text); }
.clickable { cursor: pointer; }
.clickable:hover, tr.clickable:hover td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.feed-quiet { color: var(--muted); }
.feed-quiet .feed-title { font-weight: 500; }
.feed-quiet .feed-net { justify-content: center; }
/* Group headings in a table (the readings, by the part of the boat): a band across the row, apart from the rows */
.rows tr.group th { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text);
                    background: var(--bg); padding: 6px 10px; border-bottom: none; border-radius: 6px; }
.rows tr.group + tr th, .rows tr.group + tr td { border-top: none; }
.rows tr.group:not(:first-child) th { border-top: 10px solid var(--card); background-clip: padding-box; }
