/* Bifrost operator console.
 *
 * Reference class is a signal-monitoring instrument -- a vessel traffic console,
 * a spectrum analyser, a broadcast logger -- not a web dashboard. Three rules
 * follow from that and everything below obeys them:
 *
 *   1. COLOUR IS DATA. Chrome is neutral graphite. Every hue on screen means
 *      something an operator has to act on, and each hue means exactly one
 *      thing. Red is distress and hard failure. Nothing else is ever red.
 *      Intensity ramps (the heat map) run on luminance, never round the hue
 *      wheel, because "busy" is not "urgent".
 *   2. NUMBERS HOLD STILL. Every readout that updates is mono with tabular
 *      figures, so digits do not jitter and columns of them line up.
 *   3. DEPTH COMES FROM A HAIRLINE. No shadows, no glows, no gradients on
 *      chrome. Panels butt together and share edges so the page reads as one
 *      instrument face rather than a tray of floating cards.
 *
 * No external fonts or frameworks: the box is expected to work with no route to
 * the internet, which is also why socket.io is vendored.
 */

:root {
  /* Derived tints. Kept as tokens so a change to --sig or --alarm carries into
   * the row and cell backgrounds instead of leaving a stale hand-mixed hex. */
  --sig-wash:   color-mix(in srgb, var(--sig) 13%, var(--panel));
  --alarm-wash: color-mix(in srgb, var(--alarm) 14%, var(--panel));
  /* Surfaces. Neutral and very slightly cool -- deliberately not navy, which
   * is what makes a dark UI read as a template. */
  --bg:      #0a0b0d;
  --panel:   #121417;
  --raised:  #191c20;
  --inset:   #07080a;
  --line:    #22262b;
  --line-2:  #2c3138;

  /* Text, four steps. Anything below --ink-3 is for disabled only. */
  --ink:     #e3e5e8;
  --ink-2:   #98a0a8;
  --ink-3:   #626a72;
  --ink-4:   #3c4249;

  /* The only hues in the interface. Desaturated on purpose: a saturated accent
   * on a dark ground is the signature of the look this replaces, and it also
   * destroys the contrast between "lit" and "alarming". */
  --sig:     #5fa87c;  /* carrier present, listening, healthy */
  --warn:    #c1873c;  /* wants attention before it becomes a problem */
  --alarm:   #bf4a42;  /* DISTRESS, and hard failure. Reserved. */
  --sel:     #6d93b8;  /* what you have selected, and focus */
  --lang:    #8b83b5;  /* translated from another language */

  --ui: system-ui, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;

  --r: 2px;   /* controls only; panels and cells stay square */
  --sp: 4px;  /* spacing base */
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* A component that sets its own `display` silently defeats the hidden attribute,
 * which is how the transport bar came to occupy 560px of the topbar with no
 * channel selected. Anything hidden is hidden. */
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.5 var(--ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Every number in the interface, in one rule. tabular-nums stops a changing
 * digit from reflowing its neighbours; slashed-zero keeps 0 and O apart in
 * MMSIs and channel numbers. */
.num, .pill b, .stat b, td.c-time, td.c-freq, td.c-dur, td.c-size, td.c-ch,
td.mmsi, td.pos, td.num, .chan-num, .chan-freq, .sig-db, .tile-n, .set-val,
.readout, .events, .hk-lab {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums slashed-zero;
}

::selection { background: rgba(109, 147, 184, .32); }

:focus-visible { outline: 1px solid var(--sel); outline-offset: 1px; }

/* ---------------------------------------------------------------- topbar */

.topbar {
  display: flex; align-items: stretch; gap: 20px;
  min-height: 46px; padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line-2);
  position: sticky; top: 0; z-index: 20;
  /* The topbar carries a fixed set of controls and two strips that grow with
   * the station -- the transport and the status readings -- so its content is
   * wider than some screens by design. It reflows onto another line rather
   * than running off the edge; see the responsive section for how. */
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 9px; flex: none; }
/* The wordmark carries identity through letterform and spacing, not colour.
 * A tinted logo is decoration; here colour is reserved for signal state. */
.logo {
  font: 600 14px/1 var(--ui);
  letter-spacing: .34em;
  color: var(--ink);
  text-transform: uppercase;
}
.sub { color: var(--ink-3); font-size: 11px; letter-spacing: .01em; }

/* --------------------------------------------------------------- nav tabs */

.nav { display: flex; align-items: stretch; gap: 0; flex: none; }
.nav a {
  display: flex; align-items: center;
  font: 500 11px/1 var(--ui);
  letter-spacing: .09em; text-transform: uppercase; text-decoration: none;
  color: var(--ink-3);
  padding: 0 13px;
  border-bottom: 2px solid transparent;
}
.nav a:hover { color: var(--ink); }
/* The current page is marked by a rule on the edge it shares with the content
 * below it, which is where the eye already is. */
.nav a.here { color: var(--ink); border-bottom-color: var(--sel); }

/* ------------------------------------------------------------ status strip */

/* Was eight bordered boxes wrapping onto a second row, all of equal weight.
 * Now one strip of hairline-separated readings, sized by how often an operator
 * actually needs them. */
.pills {
  display: flex; align-items: center; gap: 0;
  margin-left: auto; flex: none;
}

.pill {
  display: flex; flex-direction: column; justify-content: center; gap: 1px;
  padding: 0 12px;
  border-left: 1px solid var(--line);
  min-width: 74px; height: 30px;
}
.pill:first-child { border-left: 0; }
.pill label {
  display: block;
  font: 500 9px/1 var(--ui); letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3);
}
.pill b { font: 500 12px/1.2 var(--mono); color: var(--ink); }

/* State on the value, not on a box around it. */
.pill.ok b    { color: var(--sig); }
.pill.busy b  { color: var(--sig); }
.pill.warn b  { color: var(--warn); }
.pill.bad b   { color: var(--alarm); }
/* A zero is information, but it is never the thing to look at first. */
.pill.muted b { color: var(--ink-3); }

/* The three that matter continuously get the room. */
#pillTune b, #pillRate b { font-size: 13px; }
#pillCount, #pillAir, #pillUp { min-width: 62px; }
#pillCount b, #pillAir b, #pillUp b { font-size: 11px; color: var(--ink-2); }
/* A reading the last poll could not refresh: kept, so the operator still has
 * it, and greyed, so it is not taken for a live one. The ID outranks every
 * colour above, including the per-pill ones. */
#pills .pill.stale b { color: var(--ink-4); }

/* ----------------------------------------------------------------- panels */

/* No gap: stacked panels share a hairline and read as one face. */
main { padding: 0; display: flex; flex-direction: column; }

.panel {
  background: var(--panel);
  border-bottom: 1px solid var(--line-2);
}

.panel-head {
  display: flex; align-items: center; gap: 10px;
  min-height: 32px; padding: 0 12px;
  background: var(--raised);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
/* Sentence case at a readable size. Wide-tracked uppercase headings are for
 * field labels, not for titles you read every day. */
.panel-head h2 {
  font: 600 12px/1 var(--ui);
  letter-spacing: .01em;
  color: var(--ink-2);
  white-space: nowrap;
}
.spacer { flex: 1; }
.hint { color: var(--ink-3); font-size: 11px; }
/* The topbar stretches its children so the active tab's rule can sit on the
 * bottom edge. Loose text has to be centred back or it rides the top. */
.topbar > .hint, .topbar > .brand, .topbar > .pills, .topbar > button { align-self: center; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; }
.key {
  font: 10px/1 var(--ui); letter-spacing: .04em; color: var(--ink-3);
  display: flex; align-items: center; gap: 5px;
}
.key::before { content: ""; width: 9px; height: 2px; background: currentColor; }
.key-power  { color: var(--ink-2); }
.key-floor  { color: var(--ink-4); }
.key-open   { color: var(--warn); }
.key-marine { color: var(--sig); }

/* ----------------------------------------------------------------- inputs */

input[type=search], input[type=date], input[type=password], select, button {
  font-family: var(--ui);
  font-size: 12px;
}

input[type=search], input[type=date], input[type=password], select {
  background: var(--inset);
  border: 1px solid var(--line-2);
  color: var(--ink);
  padding: 4px 8px;
  border-radius: var(--r);
}
input[type=search] { min-width: 230px; }
input[type=date] { font: 11px/1.4 var(--mono); padding: 3px 6px; }

/* Native select and date chrome is the loudest possible break in a custom
 * interface, so it is replaced rather than tolerated. */
select {
  appearance: none;
  padding-right: 22px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
                    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: right 11px center, right 7px center;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}
input[type=date]::-webkit-calendar-picker-indicator {
  filter: invert(.55); cursor: pointer; opacity: .8;
}
input[type=date]::-webkit-calendar-picker-indicator:hover { opacity: 1; }

input[type=search]:focus, input[type=date]:focus, input[type=password]:focus, select:focus {
  outline: none; border-color: var(--sel);
}

.toggle {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--ink-2); cursor: pointer;
}
.toggle input { accent-color: var(--sel); }

/* The fleet page dresses a link that leaves the hub with this treatment, and an
 * anchor is the honest element for navigation -- middle-clickable and copyable,
 * which a button is not. Both elements are named rather than widening this to a
 * bare `.ghost`: that drops specificity from (0,1,1) to (0,1,0) and hands every
 * tie to .lb-btn and .gearbtn, which measurably restyled nine controls. */
button.ghost, a.ghost {
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  padding: 4px 10px;
  border-radius: var(--r);
  cursor: pointer;
  font-size: 11px;
  letter-spacing: .02em;
}
button.ghost:hover, a.ghost:hover { border-color: var(--ink-3); color: var(--ink); }
button.ghost.on, a.ghost.on { color: var(--ink); border-color: var(--sel); background: var(--raised); }
button.ghost:disabled {
  opacity: 1; cursor: default;
  border-color: var(--line); color: var(--ink-4);
}

/* ------------------------------------------------------------------ scope */

.scope { position: relative; background: var(--inset); padding: 0; }
#spectrum, #waterfall { display: block; width: 100%; }
#spectrum { height: 250px; }
/* Shorter than it was: at 220px the waterfall was mostly an empty black field
 * on a quiet band, which is a lot of the page saying nothing. */
#waterfall {
  height: 84px;
  border-top: 1px solid var(--line);
  image-rendering: pixelated;
}
#waterfall.hidden { display: none; }

.readout {
  position: absolute; top: 8px; right: 10px;
  background: rgba(7, 8, 10, .9);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  padding: 5px 8px;
  font: 11px/1.5 var(--mono);
  color: var(--ink-2);
  pointer-events: none;
  white-space: pre;
  opacity: 0; transition: opacity .12s;
}
.readout.on { opacity: 1; }
.readout b { color: var(--ink); font-weight: 600; }

/* --------------------------------------------------------------- channels */

.chan-groups { padding: 10px 12px 12px; }
.chan-group + .chan-group { margin-top: 14px; }
.chan-group h3 {
  font: 500 10px/1 var(--ui); letter-spacing: .11em;
  color: var(--ink-3); text-transform: uppercase;
  padding-bottom: 5px; margin-bottom: 7px;
  border-bottom: 1px solid var(--line);
}

.chan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(98px, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

/* Cells share hairlines rather than each carrying its own border and radius:
 * 92 identical rounded boxes read as decoration, a grid reads as a band plan. */
.chan {
  background: var(--panel);
  /* Own hairlines on two edges only, so neighbours share a single line and a
   * short last row leaves clean space rather than phantom cells. */
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  box-shadow: inset 2px 0 0 transparent;
  padding: 5px 7px 6px;
  cursor: pointer;
  position: relative;
  transition: background .1s;
}
.chan:hover { background: var(--raised); }
.chan.sel { background: var(--raised); box-shadow: inset 2px 0 0 var(--sel); }

.chan-top { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; }
.chan-num { font: 600 13px/1.15 var(--mono); color: var(--ink); }
.chan-tag {
  font: 500 8px/1 var(--ui); letter-spacing: .08em;
  color: var(--ink-4); text-transform: uppercase;
}
.chan-freq { font: 10px/1.4 var(--mono); color: var(--ink-3); }

.chan-meter { height: 2px; background: var(--line); margin-top: 5px; overflow: hidden; }
.chan-meter i {
  display: block; height: 100%; width: 0;
  background: var(--ink-2);
  transition: width .1s linear;
}

.chan-seen { font: 9px/1.3 var(--ui); color: var(--ink-4); margin-top: 3px; height: 12px; }

/* Role is carried on the left edge, so a column of tiles can be scanned for it
 * without reading any of them. */
.chan.distress   { box-shadow: inset 2px 0 0 var(--alarm); }
.chan.distress .chan-num { color: var(--alarm); }
.chan.nonvoice   { box-shadow: inset 2px 0 0 var(--warn); }
.chan.nonvoice .chan-num { color: var(--warn); }
.chan.heard      { box-shadow: inset 2px 0 0 var(--ink-4); }

.chan.live { background: var(--sig-wash); box-shadow: inset 2px 0 0 var(--sig); }
.chan.live .chan-meter i { background: var(--sig); }
.chan.live .chan-num { color: var(--sig); }
/* A steady dot, not a blinking one. Something genuinely is on air; the
 * interface does not need to flash to say so, and a page of blinking dots is
 * unreadable when six channels open at once. */
.chan.live::after {
  content: ""; position: absolute; top: 6px; right: 6px;
  width: 4px; height: 4px; border-radius: 50%; background: var(--sig);
}

/* Listening and recording are independent of each other and of the squelch,
 * so they are marked in different places on the cell. */
.chan-ops { display: flex; gap: 3px; margin-top: 4px; }
.chan.halted .chan-meter i { background: var(--ink-4); }
.chan.halted .chan-num { color: var(--ink-2); }

/* ------------------------------------------------------------------ table */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  font: 500 10px/1 var(--ui); letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-3);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-2);
  position: sticky; top: 0; background: var(--raised); z-index: 1;
  white-space: nowrap;
}
td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
tbody tr:hover { background: var(--raised); }

.c-time  { width: 92px; }
.c-ch    { width: 62px; }
.c-freq  { width: 92px; }
.c-dur   { width: 56px; }
.c-sig   { width: 104px; }
.c-lang  { width: 62px; }
.c-audio { width: 190px; }
.c-act   { width: 34px; }
/* Transcript and translation are the same kind of thing at the same width, but
 * not of the same rank: the translation is a convenience and is the first of the
 * two to go. Separate classes are what let them be tiered apart. */
.c-text  { min-width: 260px; }
.c-trans { min-width: 260px; }

td.c-time, td.c-freq, td.c-dur { font: 11px/1.5 var(--mono); color: var(--ink-2); }
td.c-ch { font: 600 12px/1.5 var(--mono); }
td.c-ch .side { color: var(--ink-4); font-weight: 400; font-size: 10px; }

.sig { display: flex; align-items: center; gap: 7px; }
/* One flat bar in one colour. A gradient across a measurement implies a scale
 * that is not there. */
.sig-bar { flex: 1; height: 3px; background: var(--line); overflow: hidden; }
.sig-bar i { display: block; height: 100%; background: var(--ink-2); }
.sig-db { font: 10px/1 var(--mono); color: var(--ink-3); width: 34px; text-align: right; }

/* Tags are outlined, not filled. A row of saturated chips competes with the
 * transcript, which is the thing anyone is actually reading. */
.badge {
  display: inline-block; padding: 0 5px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  font: 500 10px/1.6 var(--mono); text-transform: uppercase;
  color: var(--ink-2);
}
.badge.en  { color: var(--ink-2); }
.badge.pt  { color: var(--lang); border-color: color-mix(in srgb, var(--lang) 40%, var(--line-2)); }
.badge.oth { color: var(--ink-3); }
.badge.rej { color: var(--ink-3); border-style: dashed; }
.badge.data { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line-2)); }

/* Wraps at a word where it can and inside one only when a token -- a callsign,
 * a filename -- is longer than the column it has to live in. */
.text { max-width: 520px; overflow-wrap: break-word; }
.text.clamp {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; cursor: pointer;
}
.text.none { color: var(--ink-4); }

/* -------------------------------------------------------- audio transport */

/* The <audio> element is the engine and is never seen: `controls` draws a
 * different widget in every browser, and a table of thirty of them competes with
 * the transcripts that are the actual content. */
.ap { display: inline-flex; align-items: center; gap: 8px; }
.ap audio { display: none; }

.ap-play {
  width: 20px; height: 20px; flex: none; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  color: var(--ink-2);
  font-size: 8px; line-height: 1; cursor: pointer;
}
.ap-play:hover { color: var(--ink); border-color: var(--ink-3); }
.ap.playing .ap-play { color: var(--sig); border-color: color-mix(in srgb, var(--sig) 55%, var(--line-2)); }

.ap-bar {
  width: 96px; height: 3px; flex: none;
  background: var(--line);
  cursor: pointer;
  position: relative;
}
/* A larger hit area than the 3px the eye needs. */
.ap-bar::after { content: ""; position: absolute; inset: -7px 0; }
.ap-bar i { display: block; height: 100%; width: 0; background: var(--ink-2); }
.ap.playing .ap-bar i { background: var(--sig); }

.ap-t {
  font: 10px/1 var(--mono); font-variant-numeric: tabular-nums;
  color: var(--ink-3); min-width: 62px;
}
.ap.failed .ap-play { color: var(--ink-4); border-color: var(--line); }
.ap.failed .ap-t { color: var(--warn); }

tr.live-row { background: var(--sig-wash); }
tr.live-row td { color: var(--sig); }
/* A new row announces itself once, by fading a tint out. */
tr.fresh { animation: fresh 2s ease-out; }
@keyframes fresh { from { background: var(--raised); } to { background: transparent; } }

button.del {
  background: none; border: none; color: var(--ink-4);
  cursor: pointer; font-size: 14px; line-height: 1; padding: 2px 4px;
}
button.del:hover { color: var(--alarm); }

.empty { padding: 26px; text-align: center; color: var(--ink-3); font-size: 12px; }
.empty.hidden { display: none; }

/* ------------------------------------------------------------------ pager */

/* Both feeds on the live page are unbounded -- thousands of AIS messages in an
 * afternoon -- so each shows one page and the control sits below the rows, on
 * the panel's bottom hairline. It is hidden outright while everything fits:
 * a prev and a next that can never move are two dead controls per panel. */
.pager {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 7px 12px; border-top: 1px solid var(--line);
}
/* A page number is a readout, so it holds still like every other number here. */
.pager .hint { font: 11px/1 var(--mono); }
/* Rows that arrived while the operator was off page 1 are withheld rather than
 * inserted, so this count is the only thing on screen that says they exist. */
.pager .newer { color: var(--sig); }

/* ----------------------------------------------------------------- events */

#panelEvents.collapsed .events { display: none; }
.events {
  max-height: 200px; overflow-y: auto;
  padding: 8px 12px; background: var(--inset);
  font: 11px/1.7 var(--mono);
}
.ev { color: var(--ink-2); }
.ev time { color: var(--ink-4); margin-right: 8px; }
.ev .k { display: inline-block; width: 66px; color: var(--ink-3); }
.ev.start .k    { color: var(--sig); }
.ev.complete .k { color: var(--ink-2); }
.ev.system .k   { color: var(--warn); }

/* ----------------------------------------------------------- DSC alerts */

/* The one place in the interface allowed to be loud, because it is the one
 * event an operator must not miss. It does not pulse: a static red band with
 * real contrast is more legible than an animated one, and it still reads at a
 * glance from across a room. */
.alert-banner {
  padding: 11px 16px;
  font: 600 13px/1.4 var(--ui);
  letter-spacing: .02em;
  color: #fff;
  background: var(--alarm);
  border-bottom: 1px solid color-mix(in srgb, var(--alarm) 60%, #fff);
}
.alert-banner.urgency {
  background: color-mix(in srgb, var(--warn) 72%, #000);
  border-bottom-color: var(--warn);
}
.alert-banner.hidden { display: none; }
.alert-banner b { font-weight: 700; font-family: var(--mono); }
.alert-banner .dismiss {
  float: right; cursor: pointer;
  background: rgba(0, 0, 0, .22); border: 1px solid rgba(255, 255, 255, .45);
  color: #fff; border-radius: var(--r); padding: 1px 8px; font-size: 11px;
}
.alert-banner .dismiss:hover { background: rgba(0, 0, 0, .38); }

/* ------------------------------------------------------------- storage */

/* Storage is full: said on every page, under the top bar, for as long as it is true. In the
 * colour of something that wants attention, not the red band: red means distress and nothing
 * else, and a full disk loses audio, not a call. */
.storage-banner {
  padding: 9px 16px;
  font: 600 13px/1.4 var(--ui);
  color: #fff;
  background: color-mix(in srgb, var(--warn) 72%, #000);
  border-bottom: 1px solid var(--warn);
}
.storage-banner[hidden] { display: none; }
.storage-banner a { color: #fff; text-decoration: underline; }

/* What the unit holds and has room for, one quiet line near the top of a page. */
.storage-line, .storage-low { margin: 0; padding: 6px 16px 0; font-size: 11px; color: var(--ink-3); }
.storage-line a { color: inherit; text-decoration: none; }
.storage-line a:hover { text-decoration: underline; }
.storage-low { color: var(--warn); }
.storage-line[hidden], .storage-low[hidden] { display: none; }

/* After an export: the offer to delete what it held, where the export buttons are. */
.export-done {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 8px 12px; font-size: 12px; color: var(--ink-2);
  border-bottom: 1px solid var(--line);
}
.export-done[hidden] { display: none; }

/* In place of a player: why there is none. It wraps, because on a narrow screen the cell is
 * only as wide as the play button it stands in for. */
.c-audio .text.none { font-size: 11px; }

/* The Storage section of the settings. */
.st-line { margin: 0 0 6px; font-size: 13px; color: var(--ink); }
.st-bar { height: 6px; border-radius: 3px; margin: 10px 0 4px; }
.st-bar[hidden] { display: none; }

/* ---------------------------------------------------------- AIS vessels */

td.mmsi, td.pos, td.num { font: 11px/1.5 var(--mono); }
td.mmsi { color: var(--ink); }
td.pos  { color: var(--ink-2); }
.nav-under-way { color: var(--sig); }
.nav-moored, .nav-anchor { color: var(--ink-3); }
.vessel-name { font-weight: 600; }
tr.stale td { color: var(--ink-3); }

.dsc-distress { color: var(--alarm); font-weight: 700; }
.dsc-urgency  { color: var(--warn); font-weight: 600; }
.ecc-bad { color: var(--warn); }
.ecc-ok  { color: var(--ink-4); }

/* ============================================================== history */

/* ------------------------------------------------------- period controls */

.stepper { display: flex; align-items: center; gap: 6px; }
.panel-head h2.range {
  font: 600 14px/1 var(--ui);
  letter-spacing: .01em; text-transform: none; color: var(--ink);
  min-width: 196px;
}
button.step { font: 13px/1 var(--mono); padding: 3px 10px; }

.segmented { display: flex; }
.segmented button + button { margin-left: -1px; }
.segmented button { border-radius: 0; }
.segmented button:first-child { border-radius: var(--r) 0 0 var(--r); }
.segmented button:last-child { border-radius: 0 var(--r) var(--r) 0; }
.segmented button.on {
  position: relative; z-index: 1;
  color: var(--ink); border-color: var(--sel); background: var(--raised);
}

.heatkey { display: flex; align-items: center; gap: 3px; }
.heatkey .hk-lab { font: 10px/1 var(--mono); color: var(--ink-3); }
.heatkey .hk-lab + .chip { margin-left: 5px; }
.heatkey .chip { width: 14px; height: 10px; border: 1px solid var(--line-2); }
.heatkey .chip.inert { background: var(--inset); }

/* --------------------------------------------------------------- summary */

/* Was eight equal cards. A period summary has one headline figure and a set of
 * qualifiers, and it should look like that. */
.summary {
  display: flex; align-items: stretch; flex-wrap: wrap;
  padding: 0; border-bottom: 1px solid var(--line);
}
.summary .pill {
  min-width: 104px; height: 50px;
  padding: 0 14px;
  border-left: 1px solid var(--line);
  justify-content: center;
}
.summary .pill:first-child { border-left: 0; }
.summary .pill label { font-size: 9px; }
.summary .pill b { font: 500 16px/1.15 var(--mono); }
.summary .pill:first-child b { font-size: 20px; }
/* Nothing happened is the common case and must not draw the eye. */
.summary .pill.muted b { color: var(--ink-4); font-weight: 400; }
/* Distress is the exception that outranks the layout. */
.pill.loud { background: var(--alarm-wash); border-left-color: var(--alarm); }
.pill.loud label { color: var(--alarm); }
.pill.loud b { color: var(--alarm); }

/* ------------------------------------------------------------- heat grid */

.cal { display: grid; gap: 1px; padding: 12px; background: transparent; }
.cal-year  { grid-template-columns: repeat(6, 1fr); }
.cal-month { grid-template-columns: repeat(7, 1fr); }
.cal-day   { grid-template-columns: repeat(12, 1fr); }

.cal-dow {
  font: 500 10px/1 var(--ui); letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-4); padding: 0 0 4px 2px;
}
.cal-pad { visibility: hidden; }

.calhint { padding: 0 12px 12px; }

/* Square cells on a shared grid. The old tiles lifted and dropped a shadow on
 * hover, which is a marketing-page gesture and misreads as the data changing. */
.tile {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start;
  justify-content: space-between; gap: 8px;
  min-height: 54px; padding: 6px 8px;
  background: var(--inset);
  border: 1px solid var(--line);
  font-family: inherit; text-align: left; cursor: pointer;
  transition: border-color .1s;
}
.tile:hover { border-color: var(--sel); }
.tile:focus-visible { outline: 1px solid var(--sel); outline-offset: 1px; }
.tile-lab {
  font: 500 10px/1 var(--ui); letter-spacing: .07em; text-transform: uppercase;
  color: var(--heat-lab, var(--ink-3));
}
.tile-n { font: 500 16px/1 var(--mono); color: var(--heat-fg, var(--ink)); }

/* An empty slot is not "a little traffic": it sits flat with no heat at all so
 * the eye skips it. */
.tile.inert { border-color: var(--line); }
.tile.inert .tile-lab { color: var(--ink-4); }
.tile.inert .tile-n { font-weight: 400; color: var(--ink-4); }

.tile.sel { border-color: var(--sel); box-shadow: inset 0 0 0 1px var(--sel); }

/* Distress outranks the heat scale entirely: a quiet hour with one mayday in it
 * has to be as findable as the busiest cell on the page. This is why the heat
 * ramp itself is not allowed to use red. */
.tile.distress { border-color: var(--alarm); }
.tile-bang {
  position: absolute; top: 4px; right: 4px;
  width: 14px; height: 14px;
  background: var(--alarm); color: #fff;
  font: 700 10px/14px var(--mono); text-align: center;
}

/* ------------------------------------------------------- history listing */

.c-pick { width: 32px; }
.c-pick input { accent-color: var(--sel); }
td.c-pick { padding-top: 9px; }
#txTable.dated .c-time { width: 148px; }
#txTable.hidden { display: none; }
tr.picked { background: var(--raised); box-shadow: inset 2px 0 0 var(--sel); }
tr.picked:hover { background: color-mix(in srgb, var(--sel) 10%, var(--raised)); }

/* -------------------------------------------------------- history search */

.search { position: relative; display: flex; align-items: center; }
.search input[type=search] { min-width: 330px; padding-right: 26px; }
/* Safari draws its own clear affordance; ours is the only one that also resets
 * the scope toggle, so the native control is hidden. */
.search input[type=search]::-webkit-search-cancel-button { display: none; }
#qClear {
  position: absolute; right: 4px;
  border: 0; background: none; padding: 0 4px;
  font-size: 15px; line-height: 1; color: var(--ink-3);
}
#qClear:hover { color: var(--ink); background: none; }

mark {
  background: rgba(109, 147, 184, .26);
  color: var(--ink);
  border-radius: 0;
  padding: 0 1px;
}

@media (max-width: 1100px) {
  .cal-day { grid-template-columns: repeat(6, 1fr); }
  .cal-year { grid-template-columns: repeat(4, 1fr); }
}

/* =========================================================== recordings */

.daterange { display: flex; align-items: center; gap: 6px; }
.daterange label { font-size: 11px; color: var(--ink-3); }

/* The option list is built from the rows, so its width would otherwise move
 * the whole panel head around every time the filter changes. */
#chFilter { min-width: 210px; }

#recTable.hidden { display: none; }
#recTable .c-time { width: 148px; }
#recTable .c-ch   { width: 86px; }
#recTable .c-dur  { width: 104px; }
#recTable .c-act  { width: 64px; }
.c-size { width: 78px; }

td.c-size { font: 11px/1.5 var(--mono); color: var(--ink-2); }
/* "16 ship" reads as one channel; "16ship" reads as a typo. */
#recTable td.c-ch .side { margin-left: 4px; }
td.c-note .text { max-width: 340px; }
td.c-act { text-align: right; }

/* A gap is the one thing that makes a file untrustworthy, so it is called out
 * on the length it distorts, again in the note column, and once more down the
 * edge of the row for anyone scanning the table rather than reading it. */
.badge.gap { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line-2)); margin-left: 6px; }
.note-gap { color: var(--warn); font-size: 11px; }
tr.truncated td:first-child { box-shadow: inset 2px 0 0 var(--warn); }

/* Deleting audio cannot be undone: the first click arms the button, and only
 * the second one deletes. Armed, it stops looking like an idle affordance. */
button.del.armed {
  color: #fff; background: var(--alarm);
  border-radius: var(--r); padding: 1px 6px; font-size: 11px;
}

/* ============================================================ listening */

/* Two independent controls per channel. Neither implies the other, so they are
 * never drawn as one segmented pair. */
.lb-btn {
  background: transparent; border: 1px solid var(--line-2); color: var(--ink-3);
  border-radius: var(--r); cursor: pointer;
  font: 500 9px/1 var(--ui); letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 5px;
}
.lb-btn:hover { border-color: var(--ink-3); color: var(--ink); }
.lb-btn.on { color: var(--sig); border-color: color-mix(in srgb, var(--sig) 50%, var(--line-2)); }
.lb-btn.rec.on { color: var(--alarm); border-color: color-mix(in srgb, var(--alarm) 55%, var(--line-2)); }
.lb-btn:disabled { color: var(--ink-4); border-color: var(--line); cursor: default; }

/* The transport lives in the topbar because it belongs to the station, not to
 * whichever channel tile happens to be on screen. */
.listenbar {
  display: flex; align-items: center; gap: 8px;
  padding: 0 10px; height: 30px;
  border-left: 1px solid var(--line);
  font-size: 11px; color: var(--ink-2);
}
.listenbar.hidden { display: none; }
.listenbar .lb-ch { font: 600 12px/1 var(--mono); color: var(--ink); }
.listenbar .lb-pos { font: 11px/1 var(--mono); color: var(--sig); min-width: 58px; }
.listenbar .lb-pos.behind { color: var(--warn); }
.listenbar .lb-pos.stopped { color: var(--ink-3); }
.dot { width: 5px; height: 5px; border-radius: 50%; background: var(--sig); }
.dot.off { background: var(--ink-4); }

/* ============================================== settings & diagnostics */

/* Behind a gear because it is for commissioning a box or chasing a fault, not
 * for watching traffic. */
.gearbtn {
  margin-left: 8px; padding: 4px 8px;
  border-radius: var(--r); font-size: 13px; line-height: 1;
}
.gearbtn.on { color: var(--ink); border-color: var(--sel); }

.settings .set-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(258px, 1fr));
  gap: 1px; background: var(--line);
}
.set-block { padding: 12px 14px; background: var(--panel); }
.set-block h3 {
  font: 600 11px/1 var(--ui); letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-2); margin-bottom: 8px;
}
.set-note { font-size: 11px; color: var(--ink-3); margin-bottom: 10px; line-height: 1.5; }
.set-row { display: flex; align-items: center; gap: 8px; min-height: 24px; }
.set-row + .set-row { margin-top: 5px; }
.set-label { font-size: 11px; color: var(--ink-3); min-width: 104px; }
.set-val { font: 500 12px/1 var(--mono); color: var(--ink); }
.set-val.bad { color: var(--alarm); }
.set-unit { font-size: 11px; color: var(--ink-3); }
.hint.bad { color: var(--alarm); }

.set-meter { flex: 1; height: 4px; background: var(--line); overflow: hidden; max-width: 132px; }
.set-meter i { display: block; height: 100%; background: var(--ink-2); }
.set-meter i.hot { background: var(--alarm); }
.set-meter i.cold { background: var(--ink-4); }

input[type=range] { accent-color: var(--sel); height: 18px; }
input[type=number] {
  background: var(--inset); border: 1px solid var(--line-2); color: var(--ink);
  border-radius: var(--r); padding: 3px 6px; width: 58px;
  font: 12px/1.3 var(--mono);
}
input[type=number]:focus { outline: none; border-color: var(--sel); }

/* --------------------------------------------------------- gain calibration */

.cal-row { gap: 8px; flex-wrap: wrap; }
.cal-bar { height: 2px; background: var(--line); overflow: hidden; margin: 10px 0; }
.cal-bar i { display: block; height: 100%; width: 0; background: var(--sel); transition: width .3s linear; }
.cal-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.cal-table th {
  position: static; background: none; border-bottom: 1px solid var(--line);
  padding: 3px 8px 3px 0;
}
.cal-table td {
  padding: 3px 8px 3px 0; border-bottom: 0;
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}
.cal-table tr.cal-best td { color: var(--sig); }
.cal-table tr.cal-lost td { color: var(--ink-4); }
.cal-tag {
  font: 500 10px/1.5 var(--ui); letter-spacing: .05em; padding: 0 5px;
  border: 1px solid color-mix(in srgb, var(--sig) 45%, var(--line-2));
  border-radius: var(--r); color: var(--sig);
}
.cal-tag.lost { color: var(--ink-3); border-color: var(--line-2); }

/* ------------------------------------------------------------------ misc */

.pill.halted b { color: var(--ink-3); }
.chan.listening { border-bottom-color: var(--sel); }
.chan.recording::before {
  content: ""; position: absolute; bottom: 0; left: 0; right: 0; height: 2px;
  background: var(--alarm);
}

/* ------------------------------------------------- per-channel controls */

/* Hidden until the cell is hovered, unless the channel is doing something: an
 * operator has to see what is recording by scanning the grid, not by hovering
 * across 92 cells. On hover they take the corner the live dot uses, because at
 * that point you are acting on the channel rather than watching it. */
.chan-ops {
  position: absolute; top: 3px; right: 3px;
  display: flex; gap: 2px; opacity: 0; transition: opacity .1s;
}
.chan:hover .chan-ops,
.chan.listening .chan-ops,
.chan.recording .chan-ops { opacity: 1; }
.chan:hover.live::after { display: none; }

.chan-op {
  width: 15px; height: 15px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font: 8px/1 var(--ui);
  background: var(--inset);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  color: var(--ink-3);
  cursor: pointer;
}
.chan-op:hover { color: var(--ink); border-color: var(--ink-3); }
/* Listening is yours; recording is the station's. Different meanings, so
 * different colours, and neither of them animates. */
.op-listen.on { color: var(--sel); border-color: color-mix(in srgb, var(--sel) 55%, var(--line-2)); }
.op-rec.on { color: var(--alarm); border-color: color-mix(in srgb, var(--alarm) 60%, var(--line-2)); }

/* The transport's own state dot, and its stop control. */
.lb-live { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-4); flex: none; }
.lb-live.on { background: var(--sig); }
.lb-live.off { background: var(--ink-4); }
.lb-stop { border-color: var(--line-2); }
.lb-stop:hover { border-color: var(--alarm); color: var(--alarm); }
.listenbar.halted { border-left-color: var(--line); }
.listenbar.halted .lb-ch { color: var(--ink-2); }

/* ================================================= section layout controls */

/* Injected into every panel head by layout.js. Quiet until the head is hovered,
 * because rearranging is something you do occasionally and watching traffic is
 * what the head is for the rest of the time. */
.panel-tools { display: flex; gap: 1px; flex: none; opacity: 0; transition: opacity .1s; }
.panel-head:hover .panel-tools,
.panel-tools:focus-within { opacity: 1; }

.pt {
  width: 20px; height: 20px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r);
  color: var(--ink-3);
  font-size: 8px; line-height: 1; cursor: pointer;
}
.pt:hover { color: var(--ink); border-color: var(--line-2); }
.pt:disabled { color: var(--ink-4); border-color: transparent; cursor: default; }
.pt-hide { font-size: 13px; }
.pt-hide:hover { color: var(--warn); }

/* On a touch screen there is no hover to reveal them, and the targets have to be
 * thumb-sized. */
@media (hover: none) {
  .panel-tools { opacity: 1; }
  .pt { width: 32px; height: 32px; }
}

/* ---------------------------------------------------------- sections menu */

/* The recovery path: a hidden section takes its own controls with it, so one
 * place has to list everything. Also the fastest way to rearrange by thumb. */
.secbtn { margin-left: 8px; }

.secmenu {
  position: fixed; z-index: 40;
  min-width: 232px; max-width: calc(100vw - 16px);
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  padding: 4px 0;
  max-height: calc(100vh - 64px); overflow-y: auto;
}
.secmenu-head {
  font: 500 10px/1 var(--ui); letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); padding: 6px 12px 7px;
  border-bottom: 1px solid var(--line);
}
.secrow { display: flex; align-items: center; gap: 6px; padding: 3px 8px 3px 12px; }
.secrow:hover { background: var(--raised); }
.secrow .toggle { font-size: 12px; color: var(--ink); flex: none; }
/* A hidden section still reads its name, just at the weight of something absent. */
.secrow.off .toggle { color: var(--ink-3); }
.secmenu-foot { padding: 7px 12px 5px; border-top: 1px solid var(--line); }

@media (hover: none) {
  .secrow { padding: 6px 8px 6px 12px; }
  .secrow .pt { width: 34px; height: 34px; }
}

/* ============================================================== responsive */

/* Column priority. One vocabulary, defined once, applied to a <th> and its
 * matching <td> alike:
 *
 *   (no class)  survives a 390px phone
 *   .col-sm     hidden below 560px
 *   .col-md     hidden below 900px
 *   .col-lg     hidden below 1240px
 *
 * Nothing here names a table or a column position, so inserting a column can
 * never silently change which ones disappear. The .98 keeps each boundary off
 * the round number, so a fractional viewport width cannot fall between two
 * queries and match neither of them.
 *
 * The status strip is tiered with the same classes: those readings are columns
 * of a sort, and a second vocabulary for them would be a second thing to keep
 * in step. */
@media (max-width: 1239.98px) { .col-lg { display: none; } }
@media (max-width: 899.98px)  { .col-md { display: none; } }
@media (max-width: 559.98px)  { .col-sm { display: none; } }

/* ------------------------------------------------------------ topbar reflow */

/* Measured: the controls and readings need 1310px on one line, more while the
 * transport is up, more again with the sections button. Below that the bar stops
 * being one line: the controls keep the first, and the strips -- transport,
 * status readings, the page's own summary line -- take one of their own, each
 * scrolling on its own axis if it still cannot fit. No scrollbar on them: a
 * strip of readings is something you read, not a list you browse. */
@media (max-width: 1399.98px) {
  .topbar { row-gap: 0; }
  /* On more than one line the bar's own height no longer sets the first row's;
   * the wordmark and the tabs do. */
  .brand, .nav { min-height: 46px; }
  /* Whatever buttons the bar is carrying stay together at the far edge. */
  .topbar > .nav { margin-right: auto; }

  .topbar > .pills,
  .topbar > .listenbar,
  .topbar > .hint {
    order: 2;
    flex-basis: 100%; flex-shrink: 0;
    margin-left: 0; padding-left: 0; padding-right: 0;
    display: flex; align-items: center; min-height: 30px;
    border-left: 0; border-top: 1px solid var(--line);
    white-space: nowrap;
    overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
  }
  .topbar > .pills::-webkit-scrollbar,
  .topbar > .listenbar::-webkit-scrollbar,
  .topbar > .hint::-webkit-scrollbar { display: none; }
  /* Transport above status: it is the one being operated. */
  .topbar > .listenbar { order: 1; }
  /* First reading flush with the page edge, not inset by a cell whose dividing
   * hairline is not drawn. */
  .pill:first-child { padding-left: 0; }
  .listenbar .lb-live:first-child { margin-left: 0; }
}

/* --------------------------------------------------------- tablet and below */

@media (max-width: 899.98px) {
  .topbar { padding: 0 12px; column-gap: 14px; }
  /* A head that has wrapped needs the vertical rhythm a single line gets for
   * free from its min-height, or the rows sit on top of each other. */
  .panel-head { padding: 5px 12px; column-gap: 8px; row-gap: 5px; }

  /* The columns that survive to a tablet were sized for a 1680px table, and
   * together they are wider than the screen. Their floors come down and the
   * slack still goes to the transcript, which is the column anyone is reading;
   * the only thing that loses is the transport bar, and a short bar reads the
   * same as a long one because the figures beside it are the measurement. */
  .c-time  { width: 78px; }
  .c-ch    { width: 52px; }
  .c-text  { min-width: 170px; }
  .c-trans { min-width: 100px; }
  .c-audio { width: 130px; }
  .ap { max-width: 100%; }
  .ap-bar { width: auto; flex: 1 1 40px; min-width: 32px; }
  .ap-t { min-width: 56px; }
}

/* -------------------------------------------------------------------- phone */

@media (max-width: 559.98px) {
  .topbar { padding: 0 10px; column-gap: 10px; }
  /* The wordmark says which instrument this is; the tagline explains it to
   * someone who has never seen it. Only one of those earns 120px here. */
  .sub { display: none; }
  .nav a { padding: 0 11px; letter-spacing: .06em; }
  .pill { min-width: 0; padding: 0 11px; }
  /* The wordmark, the tabs and the buttons need three lines here, so the lines
   * are made to look like a decision: everything flush with the same left edge
   * as the first reading below it, spaced by the bar's own gap. */
  .topbar > button { margin-left: 0; }

  /* Four legible cells instead of three cramped ones. Neither the channel
   * number nor its frequency may wrap: they are what the grid is read for. */
  .chan-groups { padding: 8px 10px 10px; }
  .chan-grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
  .chan { padding: 5px 6px 6px; }
  .chan-num, .chan-freq, .chan-tag, .chan-seen { white-space: nowrap; }

  /* A measure that suits a 1680px table is a horizontal scrollbar here. */
  .text, td.c-note .text { max-width: none; }
  .c-text, .c-trans { min-width: 0; }
  th, td { padding-left: 8px; padding-right: 8px; }

  /* A field with a floor wider than the screen is what pushes a panel head off
   * the edge, so here they take the width they need by taking the line. */
  .panel-head .search, .panel-head .stepper, .panel-head .daterange { flex: 1 1 100%; }
  input[type=search], .search input[type=search], #chFilter { min-width: 0; width: 100%; }
  .daterange input[type=date] { flex: 1; min-width: 0; }
  .panel-head h2.range { min-width: 0; flex: 1; text-align: center; }

  /* One column: two of these side by side would be 180px each. */
  .settings .set-grid { grid-template-columns: minmax(0, 1fr); }
  .set-row { flex-wrap: wrap; }
  .set-label { min-width: 92px; }

  /* Twelve hour cells across a phone are 30px wide, which is narrower than the
   * label on them. Four keeps the cells square-ish and the hours legible. */
  .cal { padding: 8px; }
  .cal-day { grid-template-columns: repeat(4, 1fr); }
  .cal-year { grid-template-columns: repeat(3, 1fr); }
  .summary .pill { min-width: 84px; height: 46px; padding: 0 11px; }
}

/* ------------------------------------------------------------ touch targets */

/* A pointer that cannot hover also cannot reveal anything hover-only, and
 * cannot hit a 20px control reliably. Everything here grows in the dimension a
 * thumb needs and in no other, so the desktop instrument keeps its density. */
@media (hover: none) {
  /* The tabs are a full 46px row already, so only their width is left alone --
   * that is what lets a phone keep all three on one line. */
  button.ghost, a.ghost { padding: 9px 11px; }
  /* The gear is a glyph, so its box grows with the glyph. */
  button.gearbtn { font-size: 15px; }
  button.step { padding: 8px 14px; }
  .lb-btn { padding: 8px 7px; }
  #qClear { padding: 8px 7px; font-size: 16px; }
  .alert-banner .dismiss { padding: 5px 10px; }

  input[type=search], input[type=date], input[type=password], select { padding: 8px 9px; }
  input[type=checkbox] { width: 18px; height: 18px; }
  td.c-pick { padding-top: 8px; }
  .toggle { gap: 7px; min-height: 32px; }

  /* Hover is the only thing that reveals these on a desktop; without one they
   * simply live in the cell. */
  .chan-ops { position: static; opacity: 1; justify-content: flex-end; margin-top: 5px; }
  .chan-op { width: 34px; height: 30px; font-size: 10px; }

  .ap-play { width: 32px; height: 32px; font-size: 10px; }
  .ap-bar { height: 4px; }
  .ap-bar::after { inset: -14px 0; }
  /* The delete cross is the smallest thing anyone taps and the most expensive
   * one to hit by accident, so it gets a box rather than a bigger glyph. */
  button.del { padding: 8px 10px; font-size: 15px; }
  .tile { min-height: 64px; }
}

/* On a narrow screen the panel head wraps, and the tools were landing on a line
 * of their own below the controls -- reading as a stray row rather than as part
 * of the head. Pin them to the title line instead. */
@media (max-width: 899.98px) {
  .panel-head { position: relative; padding-right: 44px; }
  .panel-tools { position: absolute; top: 4px; right: 6px; }
}
@media (max-width: 899.98px) and (hover: none) {
  .panel-head { padding-right: 112px; min-height: 40px; }
  .panel-tools { top: 3px; }
}

/* ------------------------------------------------- audio on a small screen */

/* The transport survives to the narrowest width, because a transcript you cannot
 * check against the recording is a guess -- especially with the hallucination
 * guards this receiver needs. What goes on a phone is the scrub bar and the
 * clock, not the ability to listen.
 *
 * A transmission is a few seconds long: there is nothing in it to scrub to, and
 * the button already turns green while it plays, so state is legible without the
 * clock. Recordings can be minutes and would benefit from the bar, but at 390px
 * there is no room for it beside the columns that identify the file, and the
 * length is already in its own column. */
@media (max-width: 559.98px) {
  .ap-bar, .ap-t { display: none; }
  .ap { gap: 0; }
  .c-audio, #recTable .c-audio { width: 44px; min-width: 44px; }
  td.c-audio { padding-left: 4px; padding-right: 6px; }
}

/* Row selection is a desktop task: it exists to drive an export of chosen rows,
 * and 34px of checkbox on a 390px screen is a third of what the transcript has to
 * work with. Exporting the whole period does not need it, so it goes and the
 * space becomes reading width. */
@media (max-width: 559.98px) {
  .c-pick, td.c-pick { display: none; }
}

/* ==================================================================== the map
 *
 * Appended, and only what the chart needs: the map page is built out of the
 * classes above -- topbar, panel, panel-head, ghost, hint, set-block -- and adds
 * a canvas, the two things drawn over it, and the detail card's grid.
 */

/* 62vh keeps the chart the tallest thing on the page at every size that matters
 * and still clears the topbar and the panel head on a 600px laptop screen.
 *
 * An explicit height rather than an aspect ratio: a canvas in a flexible box
 * either drives its container's height or is driven by it, and the version where
 * the canvas won grew by a few pixels on every resize until the page scrolled. */
.mapbox { position: relative; height: 62vh; min-height: 260px; }
#chart {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--panel);
  cursor: grab;
}
#chart:active { cursor: grabbing; }
#chart:focus-visible { outline: 1px solid var(--sel); outline-offset: -1px; }

/* Said over the chart rather than instead of it: the graticule is still worth
 * looking at when nothing has been decoded yet. */
.maphint {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  padding: 6px 10px;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--r);
  pointer-events: none;
}
/* With the unit's own mark on the chart, the middle of it is where the unit is: the same
 * words go to the top, clear of the mark. */
.maphint.top { top: 14px; transform: translateX(-50%); }

/* The same face as the settings drawer. That selector is scoped to .settings, so
 * the card asks for the grid by name rather than the rule being widened from the
 * middle of this file. */
.vesselcard .set-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(258px, 1fr));
  gap: 1px;
  background: var(--line);
}
.vesselcard .set-val { font-size: 12px; }
/* A vessel name out of an AIS message is up to 20 characters and the heading is a
 * panel head, which does not wrap: truncated is better than pushing the close
 * button off the edge. */
.vesselcard .panel-head h2 { color: var(--ink); overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 899.98px) {
  /* On a phone the chart gives up height so the card under it is reachable
   * without scrolling past a screenful of water. */
  .mapbox { height: 46vh; }
}

/* ========================================================= software updates
 *
 * The fleet hub's software page is a settings grid with one running sentence (.sw-msg); the
 * receiver's Settings page borrows the release notes and the hash.
 */

.sw-msg {
  padding: 10px 12px;
  font-size: 12px; line-height: 1.5;
  color: var(--ink-2);
  border-bottom: 1px solid var(--line);
}
.sw-msg.busy { color: var(--warn); }
.sw-msg.ok   { color: var(--sig); }
.sw-msg.bad  { color: var(--alarm); }

/* Release notes keep the line breaks they were written with. */
.sw-notes { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 8px; color: var(--ink-2); font-size: 12px; }
/* What changed. Each line is a kind, outlined like every other tag here, then the sentence:
 * the kinds line up in a column, so a list is scanned by kind before it is read. */
.sw-changes { list-style: none; margin: 8px 0 0; padding: 0; }
.sw-changes li { display: flex; align-items: baseline; gap: 8px; font-size: 12px; line-height: 1.5; color: var(--ink-2); }
.sw-changes li + li { margin-top: 4px; }
.sw-kind {
  flex: none; min-width: 64px; padding: 0 5px; text-align: center;
  border: 1px solid var(--line-2); border-radius: var(--r);
  font: 500 10px/1.6 var(--mono); text-transform: uppercase;
  color: var(--ink-3);
}
/* Only what is new is picked out. Amber and red mean trouble on this console; a fix is not. */
.sw-kind.new { color: var(--sig); border-color: color-mix(in srgb, var(--sig) 40%, var(--line-2)); }
.sw-what { min-width: 0; overflow-wrap: anywhere; }
/* One build among several: its name over its lines. */
.sw-build { margin: 12px 0 0; font: 500 11px/1.4 var(--mono); color: var(--ink-3); }
.sw-head { margin: 10px 0 0; font-size: 11px; color: var(--ink-3); }
.sw-adds { margin-bottom: 10px; }
.sw-adds .set-unit { margin-top: 6px; }
.sw-earlier { margin-top: 12px; }
.sw-earlier summary { cursor: pointer; font-size: 11px; color: var(--ink-3); }
.sw-earlier summary:hover { color: var(--ink-2); }
/* Small print, by contract: an operator compares releases by version and build. */
.sw-sha { font: 10px/1.4 var(--mono); color: var(--ink-4); overflow-wrap: anywhere; margin: 6px 0 4px; }
.sw-warn { color: var(--warn); }
.sw-bad { color: var(--alarm); }

input[type=file] { font: 11px/1.4 var(--ui); color: var(--ink-2); max-width: 100%; }
input[type=file]::file-selector-button {
  font: 11px/1.4 var(--ui);
  background: transparent; color: var(--ink-2);
  border: 1px solid var(--line-2); border-radius: var(--r);
  padding: 4px 10px; margin-right: 8px; cursor: pointer;
}
input[type=file]::file-selector-button:hover { border-color: var(--ink-3); color: var(--ink); }

/* ============================================================= settings page
 *
 * A firewall's admin page: sections in a left column, one flat pane at a time (settings.js),
 * rows of label | control, small sub-headings between groups, no boxes inside boxes. Scoped to
 * .set-page: the console's settings drawer shares .set-row and .set-label and keeps its look.
 */

.set-page { flex-direction: row; align-items: stretch; min-height: calc(100vh - 47px); }

.set-nav {
  flex: none; width: 176px;
  display: flex; flex-direction: column;
  padding: 8px 0;
  background: var(--panel);
  border-right: 1px solid var(--line-2);
}
.set-nav a {
  padding: 9px 16px;
  font: 500 12px/1.3 var(--ui); color: var(--ink-2); text-decoration: none;
  box-shadow: inset 2px 0 0 transparent;
}
.set-nav a:hover { color: var(--ink); background: var(--raised); }
.set-nav a.here { color: var(--ink); background: var(--raised); box-shadow: inset 2px 0 0 var(--sel); }

.set-main { flex: 1; min-width: 0; background: var(--panel); }

/* Locked/Unlocked, and a network change waiting to be kept: above every pane. */
.set-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px;
  min-height: 40px; padding: 6px 16px;
  background: var(--raised);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.set-state { font: 600 11px/1 var(--ui); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.set-unlock { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.set-unlock label { color: var(--ink-3); }
.set-status { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.set-status.busy { color: var(--warn); }
.set-status.ok   { color: var(--sig); }
.set-status.bad  { color: var(--alarm); }
.set-netbar { box-shadow: inset 2px 0 0 var(--warn); }
.set-netbar > b { color: var(--warn); font-weight: 600; }
#netCountdown { color: var(--ink); font-variant-numeric: tabular-nums; }

.set-pane { padding: 12px 16px 28px; max-width: 760px; }
/* The locking fieldset is only a switch: no border, no legend, no box. */
.set-lockable { border: 0; padding: 0; margin: 0; min-width: 0; }
/* A format hint must not read as a value. */
.set-page ::placeholder, .login-form ::placeholder { color: var(--ink-4); opacity: 1; }

.set-page .set-row { margin-top: 6px; flex-wrap: wrap; }
.set-page .set-label { min-width: 160px; font-size: 12px; }
.set-page .set-val { line-height: 1.35; overflow-wrap: anywhere; }
.set-page input[type=text], .set-page input[type=password], .set-page textarea {
  background: var(--inset);
  border: 1px solid var(--line-2);
  color: var(--ink);
  padding: 4px 8px;
  border-radius: var(--r);
  font: 12px/1.4 var(--ui);
  width: 260px; max-width: 100%;
}
.set-page input[type=text]:focus, .set-page input[type=password]:focus, .set-page textarea:focus {
  outline: none; border-color: var(--sel);
}
.set-page select { min-width: 140px; }
.set-page textarea { display: block; width: 420px; resize: vertical; font-family: var(--mono); }
.set-page input[type=checkbox] { accent-color: var(--sel); }
/* Locked: still there to read, plainly not for pressing. */
.set-page input:disabled, .set-page select:disabled, .set-page textarea:disabled {
  color: var(--ink-4); border-color: var(--line); cursor: default;
}
/* A token is read character by character when it cannot be copied: monospace, and all of it. */
#keyToken { font-family: var(--mono); font-size: 11px; }

.set-sub {
  font: 600 10px/1 var(--ui); letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3);
  margin: 20px 0 6px; padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.set-msg { margin-top: 10px; font-size: 12px; line-height: 1.5; color: var(--ink-2); overflow-wrap: anywhere; }
.set-msg.busy { color: var(--warn); }
.set-msg.ok   { color: var(--sig); }
.set-msg.bad  { color: var(--alarm); }
.set-unit.bad { color: var(--alarm); }
.set-empty { margin-top: 6px; font-family: var(--ui); color: var(--ink-3); }
.set-link { color: var(--ink); font-size: 12px; text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }

/* The table scrolls inside the pane rather than cut off "Revoke". */
.set-keys { display: block; overflow-x: auto; width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 11px; }
.set-keys th { text-align: left; font-weight: 500; color: var(--ink-3); padding: 0 10px 4px 0; }
/* Break long key names at spaces only: "overflow-wrap: anywhere" split "Revoke" one letter per
 * line and a date mid-number. */
.set-keys td { padding: 4px 10px 4px 0; border-top: 1px solid var(--line); color: var(--ink-2); overflow-wrap: break-word; }
.set-keys td:first-child { color: var(--ink); }
.set-keys button.del { font-size: 11px; white-space: nowrap; }

/* A hub link: its state in a word, coloured as the topbar pills are (green following, amber
 * something to look at, red a key refused), its facts, and its two buttons. */
.hub-link { padding: 8px 0 10px; border-bottom: 1px solid var(--line); }
.hub-link button.del { font-size: 11px; }
.hub-state { font: 600 11px/1 var(--ui); letter-spacing: .04em; text-transform: uppercase; flex: none; }
.hub-state.ok   { color: var(--sig); }
.hub-state.warn { color: var(--warn); }
.hub-state.bad  { color: var(--alarm); }
.hub-name { font: 600 12px/1.35 var(--ui); color: var(--ink); overflow-wrap: anywhere; }
/* What a hub may do: three choices, each with the line that says what it means; and the end
 * date, a field dressed as a date field is elsewhere. A link's Change fields open under it. */
.hub-may { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.hub-may-row { display: flex; align-items: baseline; gap: 8px; font-size: 12px; color: var(--ink); cursor: pointer; }
.hub-may-row b { font-weight: 500; min-width: 80px; }
.hub-may-row input { accent-color: var(--sel); margin: 0; flex: none; }
.hub-change { margin-top: 8px; padding: 2px 0 2px 12px; border-left: 2px solid var(--line-2); }
input[type=datetime-local] {
  background: var(--inset); border: 1px solid var(--line-2); color: var(--ink);
  padding: 3px 6px; border-radius: var(--r); font: 11px/1.4 var(--mono);
}
input[type=datetime-local]:focus { outline: none; border-color: var(--sel); }
input[type=datetime-local]::-webkit-calendar-picker-indicator { filter: invert(.55); cursor: pointer; opacity: .8; }
/* An invitation is one unbroken line: wrapped wherever the field ends, not at its one hyphen. */
#hubInvite { word-break: break-all; }

/* The small chart on which a unit's place is picked: the map page's chart at a size that
 * leaves the fields above it on screen. A crosshair, because a press here places something. */
.set-page .loc-chart { height: 300px; min-height: 0; max-width: 640px; margin-top: 8px; border: 1px solid var(--line); }
#locChart { display: block; width: 100%; height: 100%; background: var(--panel); cursor: crosshair; }
#locChart:focus-visible { outline: 1px solid var(--sel); outline-offset: -1px; }
/* A port is five digits and is read whole; the list of types is long, and stays on its row. */
#locPort { width: 96px; }
#locCotAff { min-width: 130px; }
#locCotPick { min-width: 0; max-width: 300px; }

/* An alert webhook: its fields and its three buttons, ruled off from the next like a hub link. */
.alert-hook { padding: 8px 0 10px; border-bottom: 1px solid var(--line); }
.alert-hook button.del { font-size: 11px; }

/* The one confirmation dialog: a question, label: value rows, two buttons. */
.set-dialog {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(7, 8, 10, .72);
}
.set-dialog-box {
  width: 100%; max-width: 400px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
}
.set-dialog-box h3 { font: 600 13px/1.35 var(--ui); color: var(--ink); margin-bottom: 8px; }
.set-dialog-box .set-row { margin-top: 4px; align-items: baseline; }
.set-dialog-box .set-label { min-width: 120px; }
.set-dialog-box .set-val { overflow-wrap: anywhere; line-height: 1.35; }
.set-dialog-buttons { justify-content: flex-end; margin-top: 16px !important; }

/* Locked (/login): a field and a button. */
.login { max-width: 420px; }
.login-form { display: flex; gap: 8px; padding: 14px 12px; }
.login-form input[type=password] { flex: 1; min-width: 0; }
.login .set-msg { margin: 0; padding: 0 12px 12px; }

/* Phone width: the section list becomes one row of tabs above the pane, and each row stacks
 * its label over its control, full width, big enough for a thumb. */
@media (max-width: 720px) {
  .set-page { flex-direction: column; min-height: 0; }
  .set-nav {
    width: auto; flex-direction: row; padding: 0;
    overflow-x: auto; scrollbar-width: none;
    border-right: 0; border-bottom: 1px solid var(--line-2);
  }
  .set-nav::-webkit-scrollbar { display: none; }
  .set-nav a { flex: none; white-space: nowrap; padding: 13px 14px; box-shadow: inset 0 -2px 0 transparent; }
  .set-nav a.here { box-shadow: inset 0 -2px 0 var(--sel); }
  .set-bar { padding: 8px 12px; }
  .set-unlock { flex: 1 1 100%; }
  .set-unlock label { flex: 1 1 100%; }
  .set-unlock input[type=password] { flex: 1; min-width: 0; }
  .set-pane { padding: 10px 12px 28px; }
  .set-page .set-row { flex-direction: column; align-items: stretch; gap: 4px; margin-top: 10px; }
  .set-page .set-label { min-width: 0; }
  .set-page .set-label:empty { display: none; }
  .set-page input[type=checkbox] { align-self: flex-start; }
  /* 16px keeps iOS Safari from zooming into a field it focuses. */
  .set-page input[type=text], .set-page input[type=password], .set-page select, .set-page textarea {
    width: 100%; font-size: 16px; padding: 9px 10px;
  }
  .set-page button.ghost, .set-page a.ghost { padding: 11px 14px; font-size: 13px; }
  .set-page input[type=file] { font-size: 13px; }
  .set-dialog-buttons button.ghost { padding: 11px 16px; font-size: 13px; }
  .login-form input[type=password] { font-size: 16px; padding: 9px 10px; }
}
