/* ============================================================
 * /tx — the transmit station (mobile first)
 * ============================================================
 *
 * Builds on base.css (colours, type, buttons). The page
 * fills the screen: header, the field (which grows), then the
 * controls and keyer pad pinned at the bottom, under the thumb.
 */

/*
 * Four type sizes, and only four (1rem = 15px):
 *   xs  0.72rem  fine print: labels, notes, stats, the time
 *   s   0.85rem  controls and menus; the phonetic names
 *   m   1.05rem  the message, the tree, the keyboard's letters
 *   l   1.3rem   the side keys (↶ ˽ /)
 * Not type, so not on the scale: icons (svg), the pad's big dot
 * and dash, keycap Morse labels (sized to fit their key), the
 * signal lamp's full-screen ghost text, and a prosign (sized to
 * fit the column).
 */


/*
 * ============================================================
 * THE PAGE
 * ============================================================
 *
 * Type sizes, the shared measures, the page itself.
 */

/*
 * The shared measures:
 *   --fs-*       the four type sizes (above)
 *   --icon       every tappable symbol that isn't a framed button
 *                (chevrons, close and remove ×, the eye, play / pause,
 *                repeat, ♪ ☼ ≋, the tree's ><, the (i)) is drawn this
 *                size, centred in --icon-box, roomier to tap
 *   --pad-cols   dit | dah | side keys; the side keys as wide as
 *                the tree column (--edge-w), so the pad's ↵ sits
 *                right under the one on the rule
 *   --key-lit    a key lit while pressed
 *   --ui-glow    how bright the station's own lights are (a key held,
 *                the glow round the message): fixed
 *   --bar        what the eye hides, drawn as a bar in the tape's colour
 */
/* the collapsed tree column's width, as a length (so a ch here is
   the station's, wherever it's used): the ↵ in the far corner keeps a
   column as wide, so the counts sit as far in from either edge, and
   so do the pad's side keys below, its ↵ right under that one */
@property --edge-w {
  syntax: "<length>";
  inherits: true;
  initial-value: 0px;
}

.tx {
  --fs-xs: 0.72rem;
  --fs-s: 0.85rem;
  --fs-m: 1.05rem;
  --fs-l: 1.3rem;
  --icon: 1.2rem;
  --icon-box: 1.9rem;
  --edge-w: 6.5ch;
  --pad-cols: 1.7fr 2.4fr var(--edge-w);
  --row-h: 2.2rem;      /* the row under the tabs (settings, the player, the input modes) */
  --ui-glow: 0.5;
  --key-lit: color-mix(in srgb, var(--paper) calc(var(--ui-glow) * 100%), var(--bakelite));
  --bar: color-mix(in srgb, var(--paper) 80%, var(--bakelite));
}

body.tx {
  font-size: var(--fs-m);
  /* one height for the input area, whichever is showing (keyer
     pad + timing bar, keyboard, or settings), so switching between
     them never squeezes the message above. A third of the screen,
     190 to 300px; on a short screen it gives way (down to 6rem) so
     the message keeps a line: --rest is everything else, the
     header, the tabs, the player, the control row, the gaps and
     one line (measured: 285px of a 470px screen; SHORT SCREENS
     at the end takes some back) */
  --rest: 18rem;
  --input-h: max(6rem, min(300px, max(190px, 32dvh), 100dvh - var(--rest) - var(--safe-top) - var(--safe-bottom)));
  max-width: calc(520px + 2 * var(--safe-x));
  height: 100dvh;
  /* the safe areas (base.css --safe-*): what a phone's bars and notch
     cover when the page runs under them; 0 in a browser's tab */
  padding: calc(0.75rem + var(--safe-top)) calc(0.75rem + var(--safe-x))
    calc(0.75rem + var(--safe-bottom));   /* the sides alike: centred on the glass (base.css --safe-x) */
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  overflow: hidden;
}

.tx [hidden] {
  display: none !important;   /* the display rules below mustn't un-hide things */
}

.tx button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;   /* no double-tap zoom */
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ico {
  display: block;
  flex: none;
  width: var(--icon);
  height: var(--icon);
  overflow: visible;
}

/* the icon box: one size for every icon you can tap */
.edge-toggle,
.entry .x,
.popup .close,
.share-menu .close,
.player button,
.outputs button,
.tray-toggle,
.profile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--icon-box);
  height: var(--icon-box);
  padding: 0;
  border: 0;
  background: transparent;
  letter-spacing: 0;
}

.tx .frame-label { font-size: var(--fs-s); }


/*
 * ============================================================
 * HEADER
 * ============================================================
 *
 * The name, paste and share.
 */

/* the bar is every page's (base.css .top, js/shared/nav.js); here it sits
   in the station's column, with no room under it but the gap */
.tx-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 1.2ch;
}

/* the profile: a ring, greyed like paste and share; with a
   callsign, the ring holds its first character instead of the
   outline of a head (js/station/profile.js) */
.profile {
  margin-right: -0.35rem;   /* its ring, not its tap room, at the edge */
  color: var(--graphite);
}

.profile .initial {
  display: none;
  align-items: center;
  justify-content: center;
  width: var(--icon);
  height: var(--icon);
  border: 1.5px solid currentColor;
  border-radius: 50%;
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1;
}

.profile.signed .ico { display: none; }
.profile.signed .initial { display: inline-flex; }
.profile[aria-expanded="true"] { color: var(--paper); }

.share-toggle {
  border: 0;
  padding: 0.15rem 0.2rem;
  color: var(--graphite);
  background: transparent;
  font-size: var(--fs-s);
}

.share-toggle[aria-expanded="true"] {
  color: var(--paper);
  text-decoration: underline;
  text-underline-offset: 4px;
}


/*
 * ============================================================
 * THE STATION
 * ============================================================
 *
 * The box: the tree edge on the left, the field on the right, the
 * switch on its bottom edge, and a brass glow while the key is down.
 */

/*
 * The switch on the bottom edge of the message box. Drawn at
 * 30 px wide; the hinge's centre is (5.6, 21.7) inside it, and
 * sits exactly on the border line. A strip of background under
 * the lever cuts the border: open, there's a gap; closed, the
 * lever fills it.
 */
/* never shorter than one line of the message and its counts:
     the tape's padding (0.75rem) and one entry, Morse and letters
     (1.1rem + 2 rows of 1.2 × --fs-m), then the counts (0.75rem +
     2.7em of --fs-xs) and the borders. Squeezed, the input area
     gives way instead (--input-h) */
.station {
  position: relative;
  flex: 1;
  min-height: calc(0.75rem + 1.1rem + 2.4 * var(--fs-m) + 0.75rem + 2.7 * var(--fs-xs) + 3px);
  display: flex;
  border: 1px solid var(--wire);
}

.station .switch {
  position: absolute;
  z-index: 3;
  top: calc(100% + 0.5px);
  left: calc(50% - 15px);
  width: 30px;
  height: 32.5px;
  margin-top: -21.7px;
  color: var(--paper);
  pointer-events: none;
}

/* the station's switch is a straight key (station/keys.js): press it */
.station .switch {
  pointer-events: auto;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

/* never the reference page's filled hover (base.css): paper at rest
   and held (the LED says it's closed), brass to a pointer (below) */
.station .switch:hover svg { color: var(--paper); }

.station .switch::after {
  content: "";
  position: absolute;
  inset: -6px -8px;          /* a little more to aim at than the drawing */
}

.station .switch svg {
  position: relative;
  width: 30px;
  height: 32.5px;
  overflow: visible;
}

.station .switch::before {
  content: "";
  position: absolute;
  left: 1px;
  width: 28px;              /* ends where the closed lever does */
  top: calc(21.7px - 2.5px);
  height: 4px;              /* the border, and the lit border's outer ring */
  background: var(--bakelite);
}

/* lamp: a brass glow round the message area while the key is closed */
/* --ui-glow: the station's own lights, at one level */
.station.lit {
  --lit: color-mix(in srgb, var(--brass) calc(var(--ui-glow) * 100%), var(--wire));
  border-color: var(--lit);
  box-shadow:
    0 0 0 1px var(--lit),
    0 0 18px color-mix(in srgb, var(--brass) calc(var(--ui-glow) * 45%), transparent),
    inset 0 0 28px color-mix(in srgb, var(--brass) calc(var(--ui-glow) * 18%), transparent);
}

.field {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}


/*
 * ============================================================
 * THE TREE EDGE
 * ============================================================
 *
 * The collapsed tree, the about column under it, and (i).
 */

/* a size container: what's in it scales to its height, and nothing
   runs past the station's edge */
.tree-edge {
  container-type: size;
  overflow: hidden;
  flex: none;
  width: var(--edge-w);
  border-right: 1px solid var(--wire);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.4rem 0;
  gap: 0.8rem;
}

.edge-head {
  align-self: flex-start;    /* the collapsed column's width, pinned left: */
  width: 6.5ch;              /* the toggle doesn't move when the tree opens */
  flex: none;
  display: flex;
  justify-content: center;
}

.edge-toggle {
  color: var(--graphite);
  font-size: var(--fs-s);
}

/*
 * the magnified view:      E        parent
 *                          |
 *                         [A]       here
 *                         / \
 *                        R   W      children (tap = dit / dah)
 */
/* five rows; on a short station, as big as fits beside the toggle
   and (i) (6.5rem with the gaps), down to a size that still reads */
.local {
  cursor: pointer;          /* a tap opens the whole tree */
  font-size: clamp(0.6rem, (100cqh - 6.5rem) / 6.25, var(--fs-m));
  line-height: 1.25;
  white-space: pre;
  text-align: center;
  color: var(--graphite);
}

.local .here {
  background: var(--paper);
  color: var(--bakelite);
  padding: 0 0.3ch;
  font-weight: 700;
}

.local button {
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--paper);
  min-width: 2ch;
}

.signal .local .dot  { color: var(--dot); }
.signal .local .dash { color: var(--dash); }

/*
 * About, under the collapsed tree:
 *   marks, then the name (one fixed size, --fs-s),
 *   and at the foot, stacked up from the bottom: cut, misheard as.
 */
.about {
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  font-size: var(--fs-m);
  line-height: 1.15;
  text-align: center;
}

.about a {
  color: inherit;
  text-decoration: none;
}

/* the parts are buttons (copy, say, why) and a link (cut): plain */
.about button {
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

/* (.flash-tip, a moment's word over the part tapped: base.css) */

/* the marks and the name, the same room above and below the marks;
   across the column's width (the eye's bars run it, inside a little
   padding) */
.about-main {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
}

/* the marks, one per row, drawn as the keys draw them */
.about-marks {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3em;
}

.about-marks i {
  display: block;
  height: 0.42em;
  width: 0.42em;
  background: var(--paper);
}

.about-marks i.dash { width: 1.3em; }
.signal .about-marks i.dot  { background: var(--dot); }
.signal .about-marks i.dash { background: var(--dash); }

/* playing, the letter on its way: the marks fill in as they're sent,
   the rest waits in grey until it lands (station/about.js) */
.about-marks i.todo,
.signal .about-marks i.todo { background: var(--wire); }
.about.pending :is(.about-name, .about-name .stress, .about-prosign, .about-label, .about-cut b, .about-heard b) { color: var(--wire); }

/* the phonetic name, down the column (a letter's first letter bold) */
.about-name {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--graphite);
  font-size: var(--fs-s);
}

.about-name b {
  color: var(--paper);
  
}

/*
 * The name as a stair, like the old charts: each syllable steps
 * down and across, centred on the column, the stairs evenly apart
 * (station/about.js works out where each letter goes):
 *        U
 *       N
 *        I
 *      F
 *       O
 *        R
 *         M
 * --dx: place across its syllable (centred), --y: how far down, in
 * em; --h: the stair's height.
 */
.about-name.stair {
  display: block;
  position: relative;
  width: 100%;
  height: calc(var(--h) * 1em);
}

.about-name.stair > * {
  position: absolute;
  left: calc(50% + var(--dx) * 0.72em);
  top: calc(var(--y) * 1em);
  transform: translateX(-50%);
  line-height: 1;
}

/* where the stress falls (AL·fa, ho·TEL): brighter and bold */
.about-name .stress { color: var(--paper); font-weight: 700; }

/* short screens: the name on one line, small */
.about-name.flat {
  flex-direction: row;
  align-items: baseline;
  font-size: var(--fs-xs);
  letter-spacing: -0.02em;
}

/* a symbol: itself, bold and bigger, as on the card's tile (its
   word said on a tap; a stair is for spelling a name out) */
.about-name.about-symbol { font-size: calc(var(--fs-l) * 1.5); line-height: 1; }
.about-symbol b { font-weight: 700; }

/* a prosign: across, greyed, as big as the column allows */
.about-prosign {
  color: var(--graphite);
  white-space: nowrap;
  letter-spacing: -0.02em;
}

/* switched off in the tray: gone, but its room kept, so the (i) stays put */
.about.off { visibility: hidden; }


/* the foot: cut, then misheard as, sitting on the bottom */
.about-foot {
  align-self: stretch;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;             /* cut sits right on top of ~ */
  padding-bottom: 0;
}

.about-cut,
.about-heard {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: var(--fs-s);
}

.about-label {
  color: var(--graphite);
  font-size: var(--fs-xs);
  line-height: 1.2;
}

.about-heard .about-label { font-size: var(--fs-s); line-height: 0.9; }

.about-cut b,
.about-heard b { color: var(--paper); font-weight: 700; }

/* (i): the full about on the reference page, at the foot of the
   column; its box is the collapsed column's width, pinned left, so
   it doesn't move when the tree opens */
.edge-foot {
  margin-top: auto;
  align-self: flex-start;
  width: 6.5ch;
  display: flex;
  justify-content: center;
}

.edge-foot .info {
  /* level with the counts beside it: their middle is the foot's
     bottom padding and one of their two rows up (.field-foot),
     less the column's own padding */
  margin-bottom: calc(0.45rem + 1.35 * var(--fs-xs) - 0.4rem - var(--icon) / 2);
  text-decoration: none;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--icon);       /* a ring the icon size */
  height: var(--icon);
  border: 1px solid var(--graphite);
  border-radius: 50%;
  color: var(--graphite);
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1;
}

/* a station too short for the collapsed tree and (i) both (squeezed
   height): no (i), rather than half a ring, and its room to the tree */
@container (max-height: 10.25rem) {
  .edge-foot { display: none; }
  .local { font-size: clamp(0.6rem, (100cqh - 4.3rem) / 6.25, var(--fs-m)); }
}


/*
 * ============================================================
 * THE WHOLE TREE
 * ============================================================
 *
 * The tree edge opened to half the station, scaled to fit.
 */

body.tree-open .tree-edge {
  width: 50%;
}

.tree-box {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}

/* the dot / dash key: fixed size, not scaled with the tree */
.tree-legend {
  flex: none;
  text-align: center;
  font-size: var(--fs-xs);
  letter-spacing: 0.02em;
  padding-bottom: 0.4rem;
}

.signal .tree-legend .dot  { color: var(--dot); }
.signal .tree-legend .dash { color: var(--dash); }

.tree-scroll {
  flex: 1;
  min-height: 0;
  padding: 0 0.45rem 0.4rem;   /* same on both sides */
  overflow: hidden;
}

/* too big to shrink further: scroll both ways (and follow the node) */
.tree-scroll.scrolls {
  overflow: auto;
  overscroll-behavior: contain;
}

.tree-box .tree {
  margin: 0 auto;   /* centred when it fits; left-aligned (fully scrollable) when it doesn't */
  padding: 0;
  overflow: visible;
  line-height: 1;   /* rows touch, so the │ lines join up */
}

/* the marks run on past the tree's edge: ⋮ after the last node shown */
#tree { position: relative; }

#tree .more {
  position: absolute;
  width: 0.2em;               /* three dots drawn, narrower than the glyph: */
  height: 0.9em;              /* it fits in the box's padding */
  transform: translate(0.25em, -50%);
  font-size: inherit;
  color: transparent;         /* the glyph is for copying; the dots are drawn */
  background: radial-gradient(circle closest-side, var(--more, var(--paper)) 85%, transparent 100%) 0 0 / 0.2em 0.3em repeat-y;
  pointer-events: none;
}

.signal #tree .more.dot  { --more: var(--dot); }
.signal #tree .more.dash { --more: var(--dash); }


/*
 * ============================================================
 * THE TAPE
 * ============================================================
 *
 * The history, and the line being written: letters under their
 * marks, the caret, the > and the eye, rows hidden as bars, and the
 * line lighting up as it plays.
 */

.tape {
  -webkit-touch-callout: none;   /* our own long-press (paste) instead of the phone's */
  position: relative;   /* offsets measured from here */
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  list-style: none;
  padding: 0.25rem 0.6rem 0.5rem;
  overscroll-behavior: contain;   /* a pull at the top is ours, never the page's refresh */
}

/* pulling the history away (station/tape.js): a brass line runs along the
   top of the message while the finger holds; at its end, it's gone */
.field.pulling::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 2px;
  background: var(--brass);
  z-index: 4;
  animation: pull-run 1.5s linear forwards;
}

@keyframes pull-run {
  from { width: 0; }
  to   { width: 100%; }
}

.entry {
  display: flex;
  align-items: flex-start;
  gap: 0.6ch;
  padding: 0.55rem 0;
  border-bottom: 1px dashed var(--wire);
}

.entry:last-child {
  border-bottom: 0;
}

/* quick scroll (station/tape.js): a thumb on the tape's right edge, narrow
   to see and wide to grab; up while you scroll, brass while held */
.tape-thumb {
  position: absolute;
  right: 2px;
  z-index: 2;
  width: 4px;
  height: 2.6rem;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: var(--graphite);
  opacity: 0;
  pointer-events: none;
  touch-action: none;
  transition: opacity 0.25s;
}
.tx .tape-thumb { touch-action: none; }   /* a drag (outranks .tx button's manipulation) */
.tx .outputs [data-out],
.tx .input-mode { touch-action: none; }   /* held, a slide along the quick list (station/layer.js) */
.tape-thumb::before { content: ""; position: absolute; inset: -0.4rem -1rem -0.4rem -1.4rem; }   /* the finger's room */
.tape-thumb.up { opacity: 1; pointer-events: auto; }
.tape-thumb.held { background: var(--brass); }

/* the top of the history: where you clear it */
.tape-head {
  display: flex;
  justify-content: center;
  padding: 0.35rem 0 0.5rem;
  border-bottom: 1px dashed var(--wire);
}

.tape-head button {
  border: 0;
  padding: 0.1rem 0.4rem;
  font-size: var(--fs-xs);
  color: var(--graphite);
  background: transparent;
}

.tape-head button.armed {
  color: var(--brass);
}

/* on touch screens a long-press means paste, not select; and nowhere
   else at the station does a held finger start the phone's own
   selection (a word, or the ↵ glyph, highlighted with handles that
   swallow the next taps): the station is all controls. Only a real
   text box (the callsign) selects. The JS backs this up (main.js) */
@media (pointer: coarse) {
  body.tx { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  .tx :is(input[type="text"], textarea) { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
}

/* history above: the top edge fades out */
/* the fade covers only the peeking message (--peek), never the current line */
.tape.more-above {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 var(--peek, 26px));
  mask-image: linear-gradient(to bottom, transparent 0, #000 var(--peek, 26px));
}

/* every message's marker column as wide as the current line's
   (> and the eye): the history lines up with it, and the floating
   eye sits in the gutter, clear of the text */
.entry .marker {
  flex: none;
  width: var(--icon);
  color: var(--brass);
}

/*
 * Typing (text in, Morse out): the marker and the caret sit on
 * the LETTERS' line of the current message, since that's what
 * you're writing; keying, they sit on the Morse line.
 */
body[data-mode="type"] .entry.current .empty-line {
  padding-top: calc(1.05rem * 1.2);
}

/* the current line's marker: one slot per row (> and the eye) */
.entry .marker.two {
  width: var(--icon);
  display: grid;
  grid-template-rows: repeat(2, calc(1.05rem * 1.2));
  align-items: center;
  justify-items: center;     /* > and the eye share a centre line */
}

.marker .eye {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--icon);       /* the icon size, centred under (or over) the > */
  height: 100%;
  font: inherit;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--graphite);
}

/* small to look at, roomy to tap */

.marker .eye::after { content: ""; position: absolute; inset: -4px -10px; }

.marker .eye svg {
  width: 100%;
  height: auto;
  stroke: none;
}

/* back in the history: the one eye, floating at the tape's bottom
   left (station/tape.js), on a disc of the tape's colour like the × */
.tape-eye {
  position: absolute;
  z-index: 2;
  display: flex;
  width: var(--icon);
  height: calc(1.05rem * 1.2);
  border-radius: 50%;
  background: var(--bakelite);
  box-shadow: 0 0 0 0.3rem var(--bakelite);
  clip-path: inset(-0.3rem 0 -0.3rem -0.3rem);   /* not out to the right, over a bar's start */
}
.tape-eye[hidden] { display: none; }

/* held long enough to collapse: brass until it's let go */
.tx .marker .eye.armed { color: var(--brass); }

.marker .eye[aria-pressed="true"] {
  color: var(--paper);
}

/*
 * The eye: the row you're not entering, hidden as bars, or collapsed.
 * Each look is set on the whole tape (.hide-m, .collapse-p …), and
 * bars also as a class on a single letter (.bar-m, .bar-p): while the
 * eye goes between shown and bars, the line being written (.entry.anim)
 * goes over from the caret back, a letter at a time, each wearing the
 * old look until its turn (station/tape.js). The tape's own classes stand
 * aside for it. Collapsing (and opening up) is at once.
 *
 *   bars:       a bar per letter, running on across the gap to the
 *               next letter of the same word: one bar per word, even
 *               when a long word wraps (the slashes stay)
 *   collapsed:  keying, the letters' row takes no room; typing, the
 *               Morse row stays, empty (the eye keeps its place above
 *               the letters, the > and caret theirs), and the letters
 *               close up into plain text, a word space a space
 *
 *   .... . .-.. .-.. ---      ████████████████      (the row, empty)
 *    H   E  L    L   O         H   E  L    L   O    HELLO
 */
.tape.hide-p .entry:not(.anim) .line .w:not(.shown) .p,
.tape.hide-m .entry:not(.anim) .line .w:not(.shown) .m,
.tape.hide-m .entry:not(.anim) .line .w:not(.shown) .m span,
.line .c.bar-p .p,
.line .c.bar-m .m,
.line .c.bar-m .m span {
  color: transparent !important;
}

.tape.hide-p .entry:not(.anim) .line .w:not(.shown) .c::after,
.tape.hide-m .entry:not(.anim) .line .w:not(.shown) .c::after,
.line .c.bar-p::after,
.line .c.bar-m::after {
  content: "";
  position: absolute;
  left: -0.25ch;
  right: -0.25ch;
  height: 0.95em;
  background: var(--bar);
  pointer-events: none;
}

.tape.hide-p .entry:not(.anim) .line .w:not(.shown) .c:not(:last-child)::after,
.tape.hide-m .entry:not(.anim) .line .w:not(.shown) .c:not(:last-child)::after,
.line .c.bar-p:not(:last-child)::after,
.line .c.bar-m:not(:last-child)::after {
  right: -1.45ch;    /* across the 1.4ch gap to the next letter */
}

.tape.hide-p .entry:not(.anim) .line .c::after,
.line .c.bar-p::after { bottom: 0.12em; }   /* the letters row */
.tape.hide-m .entry:not(.anim) .line .c::after,
.line .c.bar-m::after { top: 0.15em; }      /* the Morse row */

/*
 * A bar is a word you can check: tap it and that word shows (its
 * spacing and all), tap again and it's a bar again. Only as bars
 * (not shown, not collapsed); the eye resets every word (station/tape.js).
 *
 *   .... ..  --.- ...- .--.       .... ..  --.- ...- .--.
 *   ██████   ███████████     tap   H   I   ███████████
 */
.tape.hide-p .entry:not(.anim) .line .w:not(.shown) .p,
.tape.hide-m .entry:not(.anim) .line .w:not(.shown) .m { cursor: pointer; }
@media (hover: hover) {
  .tape.hide-p .entry:not(.anim) .line .w:not(.shown):has(.p:hover) .c::after,
  .tape.hide-m .entry:not(.anim) .line .w:not(.shown):has(.m:hover) .c::after { background: var(--brass); }
}

/*
 * The bar's button: each hidden word's own way to be shown without a
 * pointer (station/tape.js). Nothing to see, so the word wears its focus;
 * only there as bars.
 */
.line .w .reveal { display: none; }
.tape.hide-p .entry:not(.anim) .line .w .reveal,
.tape.hide-m .entry:not(.anim) .line .w .reveal {
  display: block;
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
}
.line .w:has(.reveal:focus-visible) { outline: 1px dashed var(--brass); outline-offset: 3px; }

.tape.collapse-p .entry:not(.anim) .line .p { display: none; }
.tape.collapse-m .entry:not(.anim) .line .m { width: 0; overflow: hidden; visibility: hidden; white-space: nowrap; }
.tape.collapse-m .entry:not(.anim) .line .p { white-space: normal; }        /* no leading spaces (they set it under its code) */
.tape.collapse-m .entry:not(.anim) .line .w { column-gap: 0; }
/* a space's width, carried by the word before it: a line that wraps
   at a space starts flush, never a space in

     THE POLLS SAY DEMOCRATS          THE POLLS SAY DEMOCRATS
      ABOUT THE HOUSE         not     ABOUT THE HOUSE            */
.tape.collapse-m .entry:not(.anim) .line .slash { width: 0; margin: 0; overflow: hidden; color: transparent; }
.tape.collapse-m .entry:not(.anim) .line .w:has(+ .slash) { margin-right: 1ch; }

/* the prosigns' layout in the plain text (station/tape.js line): <AA> a
   new line, <BT> a new paragraph, set in */
.tape.collapse-m .entry:not(.anim) .line .slash:is(.br, .para) { flex-basis: 100%; height: 0; margin-bottom: -0.6rem; }
.tape.collapse-m .entry:not(.anim) .line .slash.para + * { margin-left: 2ch; }

body[data-mode="type"] .entry.current .line:not(.empty-line) .caret {
  margin-top: calc(1.05rem * 1.2);
}

.entry .line {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.6rem 0;
  font-size: var(--fs-m);
  line-height: 1.2;
}

.entry.past .line {
  cursor: pointer;
}

.entry.past {
  opacity: 0.7;
}

.entry .x {
  flex: none;
  align-self: flex-start;
  margin-top: -0.2rem;
  color: var(--graphite);
}

/* a long message, the one being written or one in the history: its ×
   stays at the top of the tape while the message scrolls under it, so
   it can always be cleared; it never leaves its own message, going
   up with the message's last line */
.entry .x {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bakelite);
  border-radius: 50%;
}

/* a message the extension sent: its × and, under it, ↗ to the page
   it came from (station/tape.js ends()), riding together at the top
   right as the × alone does; ↗ level with the text row */
.entry .ends {
  flex: none;
  align-self: flex-start;
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bakelite);
  border-radius: calc(var(--icon-box) / 2);
}
.entry .ends .x { position: static; }
.entry .src {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--icon-box);
  height: var(--icon-box);
  margin-top: -0.35rem;
  color: var(--graphite);
}
.entry .src:focus-visible { outline: 1px dashed var(--brass); outline-offset: -2px; color: var(--brass); }
@media (hover: hover) { .entry .src:hover { color: var(--brass); } }

/* words wrap whole; a letter is its code over its character */
.line .w { display: inline-flex; flex-wrap: wrap; gap: 0.6rem 1.4ch; max-width: calc(100% - 1ch); }   /* a word wider than the line breaks between letters */
.line .slash { margin: 0 1.2ch; color: var(--graphite); }
.line .c { display: inline-grid; position: relative; }   /* (the caret rides on the last one) */
.line .m, .line .p { white-space: pre; }
/* a letter longer than the line (dozens of marks, never closed): its
   marks wrap, between any two. The room for the caret after it is
   kept on the word (measured on the line); the letter is at most its
   word (a letter's own 100% - 1ch shrank one-letter words, S as ..|.) */
.line .c { min-width: 0; max-width: 100%; grid-template-columns: minmax(0, auto); }
.line .m { white-space: normal; overflow-wrap: anywhere; }
.line .m { color: var(--graphite); }
.signal .line .dot  { color: var(--dot); }
.signal .line .dash { color: var(--dash); }

/* the letter being keyed: its best guess so far, dimmed */
.line .c.partial .p { color: var(--graphite); }

/* a letter heard with a mark in doubt (RX, js/station/tape.js unsure): a
   guess, in graphite, and no more than that. A tap takes the other
   reading */
.line .c.unsure .p { color: var(--graphite); }
.line .c.unsure .p.takes { cursor: pointer; }

.caret {
  display: inline-block;
  width: 0.55ch;
  height: 1.1em;
  margin-left: 0.4ch;
  background: var(--brass);
  animation: blink 1.1s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

/* steady while keying; blinks again once you pause (and it keeps
   its blink under reduced motion: it's a state, ready or keying, not
   movement, as in any text editor) */
.caret.steady { animation: none; }

/* riding on the last letter: beside it, taking no room (so it never
   wraps alone); on the Morse row keying, the letters row typing */
.caret.tail {
  position: absolute;
  top: 0;
  left: 100%;
  margin-left: 0.4ch;
}

body[data-mode="type"] .entry.current .line .caret.tail {
  margin-top: 0;
  top: calc(1.05rem * 1.2);
}

/* playing (or paused part-way: station/player.js): no caret, the lit
   letter is where you are, and it's back once playback is over or
   stopped; keys put away: no caret at all. It keeps its room, so
   nothing on the line moves */
.entry.anim .caret { animation: none; }   /* (while the eye goes over: lit, not blinking) */
body.playback .caret,
body.reading .caret { visibility: hidden; }

/* the empty line: the caret waits in front of the hint */
.caret.first {
  margin: 0 0.8ch 0 0;
}

.empty-line {
  color: var(--graphite);
}

/*
 * playing back: marks appear as they're sounded, the letter
 * lights when its last mark is done, the rest waits dimmed
 */
.line.live .m span,
.line.live .p {
  opacity: 0.25;
  transition: opacity 0.06s linear;
}

.line.live .m .keyed,
.line.live .landed .p,
.line.live .sent .p {
  opacity: 1;
}

.line.live .landed .p .n {   /* the name, not the space before it */
  text-decoration: underline;
  text-underline-offset: 4px;
}

.entry.past.playing {
  opacity: 1;
}


/*
 * ============================================================
 * THE FIELD'S FOOT
 * ============================================================
 *
 * The counts, and return set into the rule above them, at the right,
 * where the line feeds up into the tape:
 *
 *   > ... --- ...
 *   - - - - - - - - - - - - - (↵) -
 *   1 char             2 dits
 */

.field-foot {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1ch;
  padding: 0.3rem 0.6rem 0.45rem;
  font-size: var(--fs-xs);
  color: var(--graphite);
  border-top: 1px dashed var(--wire);
}

/*
 * Each count a row: the numbers right-aligned in a column of their
 * own, the words after them, so both stay put as the numbers grow.
 *
 *    1 dit        12 dits
 *    3 dahs        3 dahs
 */
.stats {
  display: grid;
  grid-template-columns: auto auto;
  column-gap: 1ch;
  align-content: start;
  line-height: 1.35;
  min-height: 2.7em;   /* keeps the footer steady when empty */
}

.stats .n { justify-self: end; }

.stats:not(:empty) { cursor: pointer; }   /* a tap copies (station/tape.js) */
.stats.secret:not(:empty) { cursor: default; }   /* hidden by the eye: a tap only says "hidden" */

#stats-morse {
  padding-right: var(--edge-w);   /* the ↵'s column: as far in as the counts on the left */
}

.send {
  position: absolute;
  right: calc(var(--edge-w) / 2 - 1.15rem);   /* centred in a column as wide as the tree's */
  top: calc(-1.15rem - 0.5px);   /* centred on the rule */
  width: 2.3rem;
  height: 2.3rem;
  padding: 0;
  border-radius: 50%;
  /* a key like the others: the same faint tint and rule, lit
     while it's pressed (opaque, since it sits on the border) */
  border: 1px solid var(--wire);
  background: color-mix(in srgb, var(--paper) 4%, var(--bakelite));
  color: var(--paper);
  font-size: 1.3rem;   /* ↵ is small in the mono faces */
  line-height: 1;
  font-weight: 700;
  z-index: 3;
  touch-action: manipulation;
}

.send.pressed {
  background: var(--key-lit);
  color: var(--bakelite);
}

.send:disabled {
  background: var(--bakelite);
  color: var(--wire);
  cursor: default;
}


/*
 * ============================================================
 * CONTROLS
 * ============================================================
 *
 * Under the station: the note on arrival over the keys, the player,
 * and the row with settings, the outputs and the input modes.
 */

/*
 * On arrival: the same note over the keys (the input area), until
 * the first tap.
 */
.controls {
  position: relative;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.5rem;   /* room for the switch, below the box: the player
                           sits as far under it as above the row below */
}

/* the note on arrival, already seen this month: not drawn at all */
.noticed #notice { display: none; }

.notice {
  position: absolute;
  z-index: 6;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--input-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--wire);
  background: var(--bakelite);
  color: var(--paper);
  font-size: var(--fs-s);
  line-height: 1.6;
  text-align: center;
  cursor: pointer;
}

.notice-foot {
  display: flex;
  align-items: center;
  gap: 1ch;
  font-size: var(--fs-xs);
  color: var(--graphite);
}

/*
 * The tab row, under the message: tx and rx at the left, tabs whose
 * content is under them; the outputs in the middle, under the switch
 * on the box's edge (what the message comes out as); the suggestions
 * at the right, for either tab. A rule runs under it all but the tab
 * that's open, which opens into what's below.
 *
 *    ____  ____        _________
 *   / tx \/ rx \      / ♪  ☼  ≋ \       [R.] [W-] ⌝
 *  ─┘    └─────────────┴─────────┴──────────────────
 *
 * Three columns, the outer two alike, so the middle is the middle.
 */
.tab-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 1ch;
  height: 2.1rem;
  border-bottom: 1px solid var(--wire);
}

.tabs {
  display: flex;
  align-items: end;
  align-self: stretch;
  padding-left: 0.6ch;
}

/*
 * A tab, or the outputs' frame: a trapezoid, its top narrower than its
 * foot. Its two halves are skewed apart, each with its own side and
 * half the top, so the lines stay one pixel and crisp.
 */
.tab,
.outputs {
  position: relative;
  isolation: isolate;
}
.tab::before,
.tab::after,
.outputs::before,
.outputs::after {
  content: "";
  position: absolute;
  z-index: -1;
  top: 0;
  bottom: -1px;
  border-top: 1px solid var(--wire);
  pointer-events: none;
}
.tab::before,
.outputs::before {
  left: 0;
  right: 50%;
  border-left: 1px solid var(--wire);
  transform: skewX(-18deg);
  transform-origin: bottom left;
}
.tab::after,
.outputs::after {
  left: 50%;
  right: 0;
  border-right: 1px solid var(--wire);
  transform: skewX(18deg);
  transform-origin: bottom right;
}

.tab {
  height: 100%;
  min-width: 6.2ch;
  margin-right: -0.2ch;
  padding: 0.2rem 1.4ch 0;
  border: 0;
  background: transparent;
  color: var(--graphite);
  font-size: var(--fs-m);
}

/* the open tab: paper, and the rule under it gone (its foot, in the
   page's colour, lies over the row's) */
.tab[aria-selected="true"] {
  z-index: 1;
  color: var(--paper);
}
.tab[aria-selected="true"]::before,
.tab[aria-selected="true"]::after {
  border-top-color: var(--graphite);
  border-left-color: var(--graphite);
  border-right-color: var(--graphite);
  border-bottom: 1px solid var(--bakelite);
  background: var(--bakelite);
}

/* the outputs, framed as the open tab is and open below as it is, so
   they read as part of what's open (whichever tab), not a third tab */
.outputs {
  z-index: 1;
  display: flex;
  align-items: center;
  align-self: stretch;
  gap: 0.15rem;
  padding: 0.15rem 1.6ch 0;
}
.outputs::before,
.outputs::after {
  border-top-color: var(--graphite);
  border-left-color: var(--graphite);
  border-right-color: var(--graphite);
  border-bottom: 1px solid var(--bakelite);
  background: var(--bakelite);
}

.tiles {
  min-width: 0;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.3ch;
  padding-bottom: 2px;
}

/* the suggestions' own corner: on or off (js/station/layer.js) */
.chips-more {
  flex: none;
  align-self: start;
  width: 1.2rem;
  height: 1.2rem;
  padding: 0;
  border: 0;
  background: transparent;
}

/*
 * Holds a list (a long-press): a tick in the top right corner, as the
 * keyboard's keys that hold more have (.kbd .more).
 */
.holds {
  position: relative;
}
.holds::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  width: 4px;
  height: 4px;
  border-top: 1px solid var(--graphite);
  border-right: 1px solid var(--graphite);
  pointer-events: none;
}
.chips-more::after { top: 4px; right: 4px; width: 6px; height: 6px; }
/* the switch's tick is in the side that's on (below), not outside it */
.input-mode.holds::after { content: none; }
.input-mode .side { position: relative; }
.input-mode .side.on::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 4px;
  height: 4px;
  border-top: 1px solid var(--graphite);
  border-right: 1px solid var(--graphite);
  pointer-events: none;
}
/* the time's tick follows its words, wherever they end */
.player .time.holds::after { position: static; display: inline-block; vertical-align: top; margin-left: 2px; }

/*
 * Under the tabs, the panel: a row (tx: settings, the player, the
 * input modes; rx: its own switches), then the slot.
 *
 *   ⚙  ▷ 0.0s ──●─────────────── ⟲    [.-│A]
 */
.panel {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

/* one height, whatever is in it (the switch is the tallest); rx's
   view takes it over whole (body.rx below) */
.control-row {
  display: flex;
  align-items: center;
  gap: 0.8ch;
  height: var(--row-h);
  margin-top: 0.15rem;
}

/*
 * Suggestions, at the right of the tab row: a row of chips from the
 * left, solid, the first where it can be seen first. A shade at the
 * right while there are more that way, until the last is in view;
 * they scroll sideways (a drag, or a wheel), and once they have, a
 * shade at the left too, where the ones that went are. The row never
 * gets taller, so nothing moves when they come and go
 * (js/station/suggest.js).
 *
 *   at rest       [R.] [W-] [L..] │ [AGN] [AN▓▒░     more to the right
 *   scrolled    ░▒▓[L..] │ [AGN] [ANT] │ [<▓▒░     more either way
 *   at the end  ░▒▓[ANT] │ [<AA>] [<AR>]           the last in view
 *
 * The shade is a mask, so it falls to whatever is behind it, in
 * either theme.
 */
.chips {
  flex: 1;
  min-width: 0;
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 0.6ch;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

/* the shades: how far each reaches, 0 where there's nothing that way */
.chips {
  --shade-l: 0px;
  --shade-r: 0px;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--shade-l), #000 calc(100% - var(--shade-r)), transparent);
  mask-image: linear-gradient(to right, transparent, #000 var(--shade-l), #000 calc(100% - var(--shade-r)), transparent);
}
.chips.scrolled { --shade-l: 2.2rem; }
.chips.more { --shade-r: 2.2rem; }

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5ch;
  height: calc(100% - 4px);
  max-height: 2rem;
  padding: 0 0.55rem;
  border: 1px dashed var(--wire);
  background: transparent;
  color: var(--graphite);
  font-size: var(--fs-xs);
  line-height: 1;
  white-space: nowrap;
  scroll-snap-align: start;
  touch-action: pan-x;
}
.chip .chip-name { font-weight: 700; }
/* rx, nothing heard yet: an empty box where a chip will be */
.chip.blank { width: 3.4ch; pointer-events: none; }
.chip .marks { letter-spacing: 0.1ch; font-weight: 700; }

/* between the groups: letters │ words │ prosigns */
.chip-rule { flex: none; color: var(--wire); user-select: none; }

/*
 * The input modes are one switch, one button: .- ⇄ A. A press
 * anywhere on it flips to the other side. The ⇄ is brass to the
 * pointer, and the side that comes on flashes brass once, then
 * settles to paper. Each side is drawn as the framed buttons were.
 */
/*
 * Joined: the two sides in one frame, a rule between, the one that's
 * on drawn round in paper (inside the frame, so nothing moves). No ⇄:
 * one frame with two halves already says one or the other.
 *
 *   [ .- │ A ]
 */
.input-mode {
  display: flex;
  align-items: stretch;
  padding: 0;
  border: 1px solid var(--wire);
  border-radius: 0.6rem;   /* the player's */
  color: var(--graphite);
  cursor: pointer;
}

.input-mode .side.flash {
  animation: mode-flash 0.45s ease-out;
}

@keyframes mode-flash {
  from, 40% { box-shadow: inset 0 0 0 1px var(--brass); }
}

.input-mode .side {
  min-width: 3.2ch;
  padding: 0.15rem 0.5rem;
  color: var(--graphite);
  text-align: center;
}

.input-mode .side + .side { border-left: 1px solid var(--wire); }
/* the line round the one that's on follows the frame's corners */
.input-mode .side:first-child { border-radius: calc(0.6rem - 1px) 0 0 calc(0.6rem - 1px); }
.input-mode .side:last-child { border-radius: 0 calc(0.6rem - 1px) calc(0.6rem - 1px) 0; }
/* in the rounded side, the tick comes in off the curve, to sit as far
   inside it as the square side's does */
.input-mode .side.on:last-child::after { top: 5px; right: 6px; }

.input-mode .side.on {
  box-shadow: inset 0 0 0 1px var(--paper);
  color: var(--paper);
}

.outputs {
  display: flex;
  gap: 0.25rem;
}

.outputs button {
  flex: none;
  color: var(--wire);
  font-size: var(--fs-s);
}

.outputs button[aria-pressed="true"] {
  color: var(--paper);
}

/* settings: the gear (its tray takes the slot) */
.tray-toggle {
  flex: none;
  color: var(--graphite);
}
.tray-toggle[aria-expanded="true"] { color: var(--paper); }

/* the keys put away (a swipe down on the switch): neither side lit */
.input-mode { flex: none; touch-action: none; }
.input-mode.away .side.on { box-shadow: none; color: var(--graphite); }

/* phones: the row's own icons closer, so the scrub bar keeps its length */
@media (max-width: 479px) {
  .control-row { --icon-box: 1.6rem; gap: 0.5ch; }
  .control-row .input-mode .side { padding: 0.15rem 0.35rem; }
  .outputs { gap: 0; padding: 0.15rem 1.2ch 0; }
  .tab { min-width: 5.4ch; padding: 0.2rem 1.1ch 0; }
}

/* the narrowest phones: a tighter row of controls */
@media (max-width: 359px) {
  .tx { --icon-box: 1.6rem; }
}


/*
 * ============================================================
 * THE PLAYER
 * ============================================================
 *
 * Play, the scrub bar with its trace, the time, repeat.
 */

.player {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.6ch;
}

.player .play {
  min-width: 2.2ch;
  color: var(--paper);
  font-size: var(--fs-s);
}

.player .play:disabled {
  color: var(--wire);
  cursor: default;
}

/*
 * Every control in the player row has a fixed width (the icon box),
 * in every state (resting, hovered, pressed, toggled), so tapping
 * one never nudges the others sideways.
 */
.player button { flex: none; }
.player .repeat { color: var(--wire); position: relative; }

/* ×3 / ∞: in the middle of the arrow's circle, small, in brass (no
   change in width; the circle is round the icon's middle) */
.player .repeat::after {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1;
  color: var(--brass);
  pointer-events: none;
}

.player .repeat[data-repeat="three"]::after { content: "3"; }
.player .repeat[data-repeat="on"]::after    { content: "∞"; }
.player .repeat[aria-pressed="true"] { color: var(--paper); }

/* repeat, with nothing to play: greyed like play (its ×3 / ∞ too) */
.tx .player .repeat:disabled { color: var(--wire); cursor: default; }

/* the scrub bar: the signal drawn underneath, the range on top */
.seek-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.seek-wrap .trace {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 14px;
  width: 100%;
  transform: translateY(-50%);
  pointer-events: none;
}

/* held: the magnified view, above the playhead */
.seek-pop {
  position: absolute;
  z-index: 8;
  bottom: calc(100% + 6px);
  width: 9.5rem;
  height: 3.4rem;
  padding: 0.25rem;
  border: 1px solid var(--graphite);
  background: var(--bakelite);
  pointer-events: none;
}

.seek-pop canvas {
  display: block;
  width: 100%;
  height: 100%;
  /* the window's edges fade, so cut-off letters don't jar */
  -webkit-mask-image: linear-gradient(to right, transparent, #000 14%, #000 86%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 14%, #000 86%, transparent);
}

.seek {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 1.4rem;               /* a comfortable target; the line is thin */
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  touch-action: none;
}

/* the line is drawn by the trace; the range keeps only its playhead,
   a rounded column (keep its width in step with THUMB in station/player.js) */
.seek::-webkit-slider-runnable-track { height: 1px; background: transparent; }
.seek::-moz-range-track              { height: 1px; background: transparent; }

/* the playhead: brass, so it stands apart from the played signal */
.seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 4px;
  height: 18px;
  margin-top: -8.5px;
  border: 0;
  border-radius: 2px;
  background: var(--brass);
}

.seek::-moz-range-thumb {
  width: 4px;
  height: 18px;
  border: 0;
  border-radius: 2px;
  background: var(--brass);
}

.seek:disabled::-webkit-slider-thumb { background: var(--wire); }
.seek:disabled::-moz-range-thumb     { background: var(--wire); }

/* the readout: one width, the widest it can read ("59.9/59.9s"; past
   a minute, "9:59/9:59"), so the scrub bar never moves or changes
   length, whatever the message or the playhead */
.player .time {
  position: relative;
  flex: none;
  /* the widest it reads, and its tick: past it, a little room to the
     scrub bar, as much as the other gaps in a short message's
     "0.0/0.8s"; none, in the widest */
  width: calc(10ch + 6px);
  font-size: var(--fs-xs);
  color: var(--graphite);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* the player's frame: a thin rounded line round play, the time, the
   scrub bar and repeat, so they read as one thing between settings and
   the input modes. Within the row's height; brass while the player is
   active (clicked or tabbed into: the keys are its own)

     ⚙  ╭ ▷ 4.9s ──●─────────── ⟲ ╮  [.-]⇄[A]
        ╰─────────────────────────╯                  */
.player {
  align-self: stretch;   /* the row's height, so the frame is too */
  padding: 0 0.5ch;
}
.player::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid var(--wire);
  border-radius: 0.6rem;
  pointer-events: none;
  transition: border-color 0.15s;
}

.player.active::before { border-color: var(--brass); }

/* active, the keys go to the whole player, not the focused button:
   one frame, no ring inside it */
.player.active :focus-visible { outline: none; }


/*
 * ============================================================
 * THE TRAY
 * ============================================================
 *
 * Settings, in the input area's place: the lists over the faders,
 * the checkboxes in a column of their own.
 */

.tray {
  height: var(--input-h);   /* takes the pad's place, same height */
  overflow-y: auto;
  border-top: 1px dashed var(--wire);
  padding: 0.5rem 0 0.25rem;
  font-size: var(--fs-s);
  /* the lists across the top, the faders under them, and the
     checkboxes in a column of their own at the right */
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.6rem 0.5rem;
  /*
   * The faders sit in even columns, one per slider (four). The lists
   * above use the same measure: key across speed, sound ending just
   * before the vol | pitch gap, voice starting at that gap, light at
   * the far end (it has no slider: the phone's brightness dims it). A list too wide for its
   * place nudges the next one along rather than touching it.
   */
  --n: 4;
  --g: 0.3rem;                                            /* between slider columns */
  --c: calc((100% - (var(--n) - 1) * var(--g)) / var(--n)); /* one slider column */
}

.tray .switches { grid-column: 1; grid-row: 1; }
.tray .faders   { grid-column: 1; grid-row: 2; }

.flags {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-left: 0.5rem;
  border-left: 1px dashed var(--wire);
  color: var(--graphite);
}

/* the box, then its word, on a line: the boxes one column, the words
   another, wrapping there if they must */
.flags .flag {
  display: grid;
  grid-template-columns: 4ch minmax(0, 1fr);    /* 4ch: "[ ] " */
  align-items: baseline;
  font-size: var(--fs-xs);
}

.flags .flag .check {
  font-size: var(--fs-xs);
}

/* the report: the last of the checkboxes, a dotted word like theirs
   (under pretty, in the column or the phone's pairs) */
.flags #report {
  justify-self: start;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--graphite);
  font-size: var(--fs-xs);
  text-decoration: underline dotted;
  text-underline-offset: 0.25em;
}

/* the word opens what it means (dotted, like a term to look up); the [ ] switches */
.flag-word {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--graphite);
  font-size: var(--fs-xs);
  text-align: left;
  text-decoration: underline dotted;
  text-underline-offset: 0.25em;
}

/* how long the words stay, at the speed set now */
.suggest-now { color: var(--paper); }

/* faders: radio-panel style columns, value on top, label below,
   grouped in pairs with the group's name underneath */
.faders {
  min-height: 140px;   /* sliders stay usable; a short phone scrolls the tray */
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  column-gap: var(--g);
}

.faders .group:has(.pair > .fader + .fader) { grid-column: span 2; }

.group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.2rem;
}

.pair {
  flex: 1;
  display: flex;
  gap: var(--g);       /* the same as between groups: every slider evenly spaced */
}

.group-name {
  text-align: center;
  color: var(--graphite);
  border-top: 1px solid var(--wire);
  padding-top: 0.15rem;
  font-size: var(--fs-xs);
}

.fader {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.fader output {
  color: var(--paper);
  font-size: var(--fs-s);
}

.fader span {
  color: var(--graphite);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

/*
 * Vertical: low at the bottom, high at the top. Drawn like the scrub
 * bar: a thin line, brass up to the level (--p, station/settings.js), and
 * a brass bar across it for the handle (its touch target taller than
 * it looks). Above farnsworth's reach the line gives way to the cap.
 *
 *     │
 *     │       the line (wire)
 *    ━━━      the handle: a bar, 4px of an 16px target
 *     ┃       brass, down to the bottom
 *     ┃
 */
.fader input[type="range"] {
  --r: 8px;                 /* half the handle's target: its centre travels r … height − r */
  --at: calc(var(--r) + var(--p, 0.5) * (100% - 2 * var(--r)));
  flex: 1;
  min-height: 0;
  width: 2rem;
  margin: 0;
  writing-mode: vertical-lr;
  direction: rtl;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(to top,
      var(--brass) 0 var(--at),
      var(--wire) 0 calc(100% - var(--f, 0) * (100% - 2 * var(--r))),
      transparent 0) center / 2px 100% no-repeat;
  cursor: pointer;
  touch-action: none;
  position: relative;
  z-index: 1;               /* the handle over farnsworth's cap */
}
.fader input[type="range"]::-webkit-slider-runnable-track { background: transparent; border: 0; }
.fader input[type="range"]::-moz-range-track              { background: transparent; border: 0; }
.fader input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 16px;
  border: 0;
  background: linear-gradient(var(--brass), var(--brass)) center / 100% 4px no-repeat;
}
.fader input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 16px;
  border: 0;
  border-radius: 0;
  background: linear-gradient(var(--brass), var(--brass)) center / 100% 4px no-repeat;
}
.fader input[type="range"]:disabled { background-image: linear-gradient(var(--wire), var(--wire)); }
.fader input[type="range"]:disabled::-webkit-slider-thumb { background-image: linear-gradient(var(--wire), var(--wire)); }
.fader input[type="range"]:disabled::-moz-range-thumb     { background-image: linear-gradient(var(--wire), var(--wire)); }

/* farns.: a name that explains itself (a popup), not part of the slider */
.tx .fader .fader-name {
  border: 0;
  padding: 0;
  background: none;
  font: inherit;
  line-height: inherit;
  color: var(--graphite);
  font-size: var(--fs-xs);
  white-space: nowrap;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  cursor: help;
}
@media (hover: hover) {
  .tx .fader .fader-name:hover { color: var(--brass); }
}
.farns-eg { white-space: pre; font-size: var(--fs-xs); color: var(--graphite); }
.farns-eg span:not(.dot):not(.dash) { color: var(--paper); }

/*
 * farnsworth can't be faster than wpm: the track above wpm is out
 * of reach, drawn as a dotted, greyed stretch the thumb tops out
 * against. --f: how much of the travel is out of reach (station/settings.js);
 * --r: the thumb's radius (its centre travels r … height − r).
 */
.fader .track {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  --f: 0;
  --r: 8px;
}

.fader .track .cap {
  position: absolute;
  top: 0;
  left: 50%;
  width: 10px;
  transform: translateX(-50%);
  height: calc(var(--f) * (100% - 2 * var(--r)));
  z-index: 0;               /* under the handle */
  background:
    repeating-linear-gradient(to bottom, var(--graphite) 0 2px, transparent 2px 5px) center / 2px 100% no-repeat,
    var(--bakelite);
  opacity: 0.8;
  pointer-events: none;
}

/* not used by the current choice (the flashlight has no level) */
.fader:has(input:disabled) {
  opacity: 0.38;
}

/* the choices: lined up over the faders (see the columns above) */
.switches {
  display: grid;
  /* key and sound (up to the vol | pitch gap) | voice | light, at the end */
  grid-template-columns:
    calc(2 * var(--c) + var(--g))
    calc(var(--c) + var(--g))
    minmax(calc(var(--c) + 2 * var(--g)), max-content)
    minmax(0, 1fr);
  row-gap: 0.35rem;
  color: var(--graphite);
  container-type: inline-size;   /* .lead measures a slider column on it */
}

/* each list its own width, with soft room before the next */
.switches label {
  position: relative;
  justify-self: start;
  margin-right: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  font-size: var(--fs-xs);
}

/* our own small chevron (the browser's is wide): room for "color" */
.switches select {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-size: var(--fs-xs);
  color: var(--paper);
  background: transparent;
  border: 0;
  border-radius: 0;
  border-bottom: 1px dotted var(--graphite);
  padding: 0.1rem 0.75rem 0.1rem 0;
  width: 12.5ch;           /* every list one width, room for the longest ("signal lamp") */
  text-overflow: ellipsis;
  cursor: pointer;
}

/* color: the name, and [x] under it */
.switches option {
  background: var(--bakelite);
  color: var(--paper);           /* not the select's hover brass */
}

.switches select:disabled {
  color: var(--graphite);
}


/* key centred over speed, sound against the vol | pitch gap; crowded, key gives way */

.switches .lead {
  --c: calc((100cqw - (var(--n) - 1) * var(--g)) / var(--n));   /* a slider column, measured on the row */
  grid-column: 1 / 3;
  display: grid;
  grid-template-columns: minmax(min-content, calc(2 * var(--c) + var(--g))) max-content;
  justify-content: space-between;
  min-width: 0;
}

.switches .lead > label:first-child { justify-self: start; margin-right: 0; }
.switches label:has(#opt-voice) { grid-column: 3; }                       /* voice, from that gap */
.switches > label[data-needs="light"] { grid-column: 4; margin-right: 0; justify-self: end; } /* light, at the end */

/* the lists' chevron: drawn, so it can turn brass with the rest */

.switches label:has(select)::after {
  content: "";
  position: absolute;
  right: 0.2rem;
  bottom: 0.55rem;
  width: 0.28rem;
  height: 0.28rem;
  border-right: 1.2px solid var(--graphite);
  border-bottom: 1.2px solid var(--graphite);
  transform: rotate(45deg);
  pointer-events: none;
}

/* placed by placeSwitches() (station/settings.js): each list over its slider(s) */
.switches.placed { display: block; position: relative; }
.switches.placed .lead { display: contents; }
.switches.placed label { position: absolute; top: 0; margin: 0; }

/*
 * Phones (480px and less): no room to line the lists up over their
 * sliders, so the lists are a row of their own, four even columns;
 * under it the sliders, a little tighter, and the checkboxes a column
 * beside them, the report at the foot, level with the sliders'
 * group names:
 *
 *   key      sound    voice    light
 *   10  10  50  600  50   [ ] ctrl
 *   │   │   │   │    │    [ ] mouse
 *   │   │   │   │    │    [x] suggest
 *   │   │   │   │    │    …
 *   wpm far vol pit  lev  [ ] pretty
 *   speed   noise    light  report…
 */
@media (max-width: 480px) {
  .tray {
    grid-template-columns: minmax(0, 1fr) max-content;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 0.6rem 0.5rem;
  }
  .tray .switches {
    grid-column: 1 / -1;
    grid-row: 1;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    column-gap: 0.4rem;
  }
  .switches .lead { display: contents; }
  .switches label,
  .switches .lead > label:first-child,
  .switches > label[data-needs="light"] { justify-self: stretch; align-self: start; margin: 0; min-width: 0; }
  .switches select { width: 100%; }
  .tray .faders {
    grid-column: 1;
    grid-row: 2;
    min-height: 150px;
    --g: 0.15rem;          /* tighter: room for the column beside */
  }
  .tray .flags {
    grid-column: 2;
    grid-row: 2;
    align-self: stretch;
    justify-content: space-between;   /* the report down at the group names */
    gap: 0.15rem;
    padding: 0 0.6rem 0 0.4rem;      /* right: clear of the tray's scrollbar, which phones draw over the edge */
  }
  .tray .flags .flag { grid-template-columns: 4ch auto; }
  /* the captions under slim columns */
  .tray .fader span,
  .tx .tray .fader .fader-name { letter-spacing: -0.06em; font-size: 0.66rem; }
  .tray { overflow-x: clip; }
}

/* a checkbox's real input: inside its box, never past the edge */
.flag .check input { left: 0; top: 0; }

/*
 * A setting whose output (♪ ☼ ≋) is off: greyed, but still
 * touchable. Touching it switches the output on.
 */
.tray [data-needs] {
  transition: opacity 0.15s linear, filter 0.15s linear;
}

/* .covered: the voice list while the sound says the marks (Di-Dah) */
.tray .idle,
.tray .covered {
  opacity: 0.38;
  filter: grayscale(1);
}

/* the tray scrolls, so it clips at its edges: a focus outline standing
   off its control (base.css) lost its left side on the key list.
   Inside the tray it draws just inside the control instead */
.tray :focus-visible,
.tray .check:has(input:focus-visible) { outline-offset: -1px; }


/*
 * ============================================================
 * THE TIMING TRAIN
 * ============================================================
 */

/* one bar over the whole pad: time zero at its left edge (the dit
   key's), marked by an upright line; key down and key up both fill
   rightward from it (station/keys.js: the timing train). A tap says what
   it shows (a popup) */
.train {
  position: relative;
  cursor: pointer;
  flex: none;
  height: 1.6rem;   /* exactly what the pad gives up for it (THE PAD): the slot's height
                       never changes, so the player above stays put on a switch */
  font-size: var(--fs-xs);
  color: var(--graphite);
}

.train .seg {
  position: relative;
  height: 1.6rem;
  border: 1px solid var(--wire);
  border-left: 0;   /* the origin line is its left edge */
  overflow: hidden;
  isolation: isolate;   /* so a finished fill can sit under the running one, but over the bar */
}

/* the note on arrival covers the train; its origin line pokes out above */
.controls:has(#notice:not([hidden])) .train .origin { visibility: hidden; }

.train .origin {
  position: absolute;
  top: -3px;
  bottom: -3px;
  left: 0;
  width: 2px;
  background: var(--graphite);
  border-radius: 1px;
  pointer-events: none;
}

.train .fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: color-mix(in srgb, var(--paper) 22%, var(--bakelite));   /* key up: grey */
}

.signal .train .fill.dot  { background: color-mix(in srgb, var(--dot) 55%, var(--bakelite)); }
.signal .train .fill.dash { background: color-mix(in srgb, var(--dash) 55%, var(--bakelite)); }
/* the length just finished (a mark, or a space), kept dimmed under
   the running one */
.train .fill.past         { opacity: 0.4; z-index: -1; }
/* on time (station/keys.js): a brass edge inside the fill, so it never
   changes size; a length finished on time stays brighter */
.train .fill.landed       { box-shadow: inset 0 0 0 2px var(--brass); }
.train .fill.past.landed  { opacity: 0.75; }

/* a tick: a dotted line through the bar, its symbol beside it. Key
   down's sit left of the line (the stretch they end), key up's right
   of it (the stretch they start), so the dit's . and the letter
   space's ˽ share one line: .┊˽ */
.train .tick {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  color: var(--wire);              /* greyed out until it's what you'd get */
  font-size: var(--fs-s);
  font-weight: 700;
  pointer-events: none;
  transition: color 0.05s linear;
}

.train .tick.down { transform: translateX(-100%); border-right: 1px dotted var(--wire); padding-right: 0.4ch; }
.train .tick.up   { border-left: 1px dotted var(--wire); padding-left: 0.4ch; }
.train .tick.edge { border-right: 0; }   /* the word space: the bar's own edge is its line */

/* where one call turns into the next (dit → dah, nothing → ˽ → /) */
.train .tick.down.split { padding: 0; border-right: 1px solid var(--brass); }
.train .tick.up.split   { padding: 0; border-left: 1px solid var(--brass); }
.train .tick.lit        { color: var(--paper); border-color: var(--graphite); }

/* playback: where the ideal length ends (a bright notch top and bottom) */
.train .ideal {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 2px solid var(--paper);
  margin-left: -1px;
  pointer-events: none;
}

.train .ideal::before,
.train .ideal::after {
  content: "";
  position: absolute;
  left: -4px;
  border: 3px solid transparent;
}

.train .ideal::before { top: 0;    border-top-color: var(--paper); }
.train .ideal::after  { bottom: 0; border-bottom-color: var(--paper); }
.signal .train .tick.lit.dot     { color: var(--dot); }
.signal .train .tick.lit.dash    { color: var(--dash); }


/*
 * ============================================================
 * THE PAD
 * ============================================================
 */

/*
 * The slot under the control row: settings, the timing bar and the
 * pad, or the keyboard. Its height is set, whatever is in it, so the
 * player and the station above never move when one replaces another
 * (or when a browser draws one a few pixels taller). Read mode puts
 * the keys away: the slot goes, and the message has the room.
 */
.slot {
  flex: none;
  height: var(--input-h);
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;   /* the timing bar to the pad, as the controls' own gap was */
}

body.reading .slot { display: none; }

/*
 * Put away, the row over the slot keeps only what's still wanted.
 * Transmitting, the player has the row to itself, full width (no
 * settings, no input modes: a tap in the message, the open tab, or
 * Esc, brings the keys back). Receiving, the recorder's deck alone
 * stays, under the tabs: no row (settings, the note, open, save), no
 * scope. A tap on the open tab puts either away, too.
 *
 *   tx   ╭ ▷ 0.0/4.9s ──●──────────────── ⟲ ╮
 *   rx   [ ● ][ ▶ ][ ❚❚ ][ ◀◀ ][ ▶▶ ][ ■ ][ × ]
 */
body.reading:not(.rx) .control-row > :is(.tray-toggle, .input-mode) { display: none; }
body.rx.reading .control-row { display: none; }
body.rx.reading .slot { display: flex; height: auto; }
body.rx.reading .rx > :not(.deck) { display: none; }

/*
 * Receiving (rx, its tab): the hearing view, a tape recorder
 * (js/station/rx.js), in the slot where the keys were. The row over it is
 * rx's own: sound or light at the left, isolate at the right, where
 * tx has settings, the player and the input modes. The suggestions
 * stay, in the tab row, for either tab.
 *
 *   ┌──────────────────────────────────────┐
 *   │          C     Q         D    X      │
 *   │          ▄ ▄▄▄ ▄     ▄▄▄ ▄▄▄ ▄       │
 *   │ 6 s            600 Hz · sine · 18 wpm │   a meter's corners
 *   └──────────────────────────────────────┘
 *   [ ● ][ ▶ ][ ❚❚ ][ ◀◀ ][ ▶▶ ][ ■ ][ × ]     the deck
 *   Heard on this device only …   open a file…  save a .wav
 *
 * The scope is a control too: a tap is rec, then pause; not
 * recording, a drag winds the tape (touch-action: none, so a drag
 * and a pinch are the scope's, not the page's).
 */
/*
 * The row over the slot is the open tab's: settings first either way,
 * then tx's player and input modes, or rx's line (the note, open a
 * file…, save a .wav). The slot keeps its height, so nothing above or
 * below moves; settings opens in it, over rx's view as over the keys.
 *
 *   tx   ⚙  ╭ ▷ 0.0/4.9s ──●──── ⟲ ╮  [.-│A]
 *   rx   ⚙  Heard on this device only: …   open a file…  save a .wav
 *
 * The toggles stay, and say what's read: ♪ or ☼ in paper, whichever
 * rx's switch (out of sight) has on; ≋ greyed, nothing to read there.
 */
body.rx .control-row > :not(.tray-toggle, .rx-row) { display: none; }
body:not(.rx) .rx-row { display: none; }

.rx-row {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 1.4ch;
}
body.rx .outputs button { color: var(--wire); }
body.rx[data-rx-medium="sound"] .outputs [data-out="sound"],
body.rx[data-rx-medium="light"] .outputs [data-out="light"] { color: var(--paper); }
body.rx .outputs [data-out="vibrate"] { opacity: 0.45; pointer-events: none; }
body.rx .outputs [data-out="vibrate"]::after { content: none; }

.rx {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  height: 100%;
  min-height: 0;
}

.rx-screen {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}

.rx-scope {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 1px solid var(--wire);
  background: color-mix(in srgb, var(--paper) 4%, var(--bakelite));
  cursor: pointer;
  touch-action: none;
}

/*
 * Light: the camera's picture over the scope, the bigger share of
 * the screen (it's what's aimed by).
 *
 *   ┌─────────────────────────────┐ [+]
 *   │         ┌ ┐                 │ 2×    the picture, and the ring;
 *   │         └ ┘                 │ [−]   the zoom beside it, never
 *   └─────────────────────────────┘       over it (the lamp may be
 *   ┌────────────────────────────────┐    anywhere in the picture)
 *   │  ▄ ▄▄▄ ▄    ▄▄▄ ▄▄▄ ▄          │   the scope, as ever
 *   └────────────────────────────────┘
 */
.rx.light .rx-screen { flex-direction: column; gap: 0.45rem; }
.rx.light .rx-scope { flex: 2; }
.rx-eye {
  position: relative;
  flex: 3;
  min-height: 0;
  display: flex;
  gap: 0.45rem;
}
.rx-eye[hidden] { display: none; }
.rx-picture {
  flex: 1;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--wire);
  background: color-mix(in srgb, var(--paper) 4%, var(--bakelite));
  cursor: crosshair;
  touch-action: none;
}
.rx.on .rx-picture { border-color: var(--graphite); }
/* (there, so the browser keeps it playing, and not to be seen) */
.rx-video {
  position: absolute;
  left: 0;
  top: 0;
  width: 2px;
  height: 2px;
  opacity: 0;
  pointer-events: none;
}
/* the other camera, in the picture's top corner: grey, brass to the touch */
.rx-flip {
  position: absolute;
  left: 0.35rem;
  top: 0.35rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--wire);
  background: var(--bakelite);
  color: var(--graphite);
  font-size: var(--fs-s);
  line-height: 1.2;
}
.rx-flip[hidden] { display: none; }
@media (hover: hover) {
  .rx-flip:hover { border-color: var(--brass); color: var(--brass); }
}

/* the zoom: a fader as the settings' are (.fader), beside the
   picture, as tall as it: how far at the top, "zoom" at the foot */
.rx-zoom {
  flex: none;
  width: 4ch;
  line-height: 1;
}
.rx-zoom output { width: 4ch; text-align: center; font-size: var(--fs-xs); }

.rx.on .rx-scope { border-color: var(--graphite); }
.rx.drop .rx-scope { border-color: var(--brass); }      /* a file held over it: let go, and it's read */
.rx.paused .rx-scope { cursor: grab; }
.rx.paused .rx-scope:active { cursor: grabbing; }

/* the meter's corners: how much is across the scope (and how far
   back the tape stands), and the sender as heard. Over the canvas,
   out of the finger's way */
.rx-span, .rx-read {
  position: absolute;
  bottom: 0.3rem;
  color: var(--graphite);
  font-size: var(--fs-xs);
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
}
.rx-span { left: 0.5rem; }
.rx-read { right: 0.5rem; }

/*
 * The deck: seven keys in one bar, as on a cassette recorder, each
 * its sign over its name. Grey at rest; the one that's down is
 * paper (rec's lamp, brass); one with nothing to do is dimmed.
 */
.deck {
  flex: none;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border: 1px solid var(--wire);
}

.deck button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.35rem 0 0.3rem;
  border: 0;
  border-left: 1px solid var(--wire);
  border-radius: 0;
  color: var(--graphite);
  background: transparent;
  font-size: var(--fs-xs);
  line-height: 1;
}
.deck button:first-child { border-left: 0; }
.deck button .ico { width: 1.15rem; height: 1.15rem; }
.deck button:disabled { opacity: 0.4; cursor: default; }
.deck button[aria-pressed="true"] {
  color: var(--paper);
  background: color-mix(in srgb, var(--paper) 7%, var(--bakelite));
}
.deck #rx-rec[aria-pressed="true"] .ico { color: var(--brass); }
.deck #rx-clear.armed { color: var(--brass); }

.rx-note {
  flex: 1;
  min-width: 0;
  line-height: 1.25;   /* two lines, on a phone, in the row's height */
  margin: 0;
  color: var(--graphite);
  font-size: var(--fs-xs);
}

/* open a file…, save a .wav: words to press, as paste and share are */
.rx-link {
  flex: none;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--graphite);
  font-size: var(--fs-xs);
  white-space: nowrap;
  text-decoration: underline dotted;
  text-underline-offset: 0.25em;
}
.rx-link:disabled { opacity: 0.4; cursor: default; text-decoration: none; }
.rx-link[hidden] { display: none; }

.pad {
  display: grid;
  grid-template-columns: var(--pad-cols);
  grid-template-rows: repeat(4, minmax(0, 1fr));   /* the side, at the right: ˽ / ⌫ ↵ */
  min-height: 0;   /* its set height, never its keys' (or the station above moves) */
  gap: 6px;
  height: var(--input-h);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.key {
  border: 1px solid var(--wire);
  background: color-mix(in srgb, var(--paper) 4%, var(--bakelite));
  color: var(--paper);
  padding: 0;
  font-size: var(--fs-l);
}

/* a press is a press, never a scroll: a finger can slide from dit
   onto dah (heavy fists, station/keys.js). (.tx here to outrank .tx
   button's manipulation, which let the browser take a sliding finger
   for a scroll and cancel the press.) */
.tx .key { touch-action: none; }

.key.dit  { grid-column: 1; }
.key.dah  { grid-column: 2; }
.key.side { grid-column: 3; line-height: 1; }   /* a glyph, not a line: four of them
                                                   share the pad's height (20px each on
                                                   a phone on its side) */

.key.dit,
.key.dah {
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}

.key b {
  font-size: 2.6rem;
  line-height: 1;
}

.key span {
  font-size: var(--fs-s);
  color: var(--graphite);
}

.signal .key.dit b { color: var(--dot); }
.signal .key.dah b { color: var(--dash); }

/* straight key: one big key across both columns */
body[data-key="straight"] .key.dah { display: none; }
body[data-key="straight"] .key.dit { grid-column: 1 / span 2; }

/* playback: the key that makes the sound, half-lit */
.key.ghost,
.key.ghost:hover {
  background: color-mix(in srgb, var(--paper) calc(var(--ui-glow) * 28%), var(--bakelite));
  border-color: var(--graphite);
}

.key.pressed,
.key.pressed:hover {
  background: var(--key-lit);
  color: var(--bakelite);
}

.key.pressed b,
.key.pressed span {
  color: var(--bakelite) !important;
}

/* the timing bar shares the input area's height with the pad */
body:has(#train:not([hidden])) .pad {
  height: calc(var(--input-h) - 1.6rem - 0.45rem);   /* the bar, and the gap above the pad */
}


/*
 * ============================================================
 * THE KEYBOARD
 * ============================================================
 *
 * Type mode's keys, their codes, the long-press fan.
 */

.type {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: var(--input-h);
  min-height: 0;   /* the same height as the pad, exactly: nothing above moves on a switch */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.kbd {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: repeat(4, minmax(0, 1fr));   /* rows as the slot allows, never their keys' own height */
  gap: 5px;
}

/* 20 half-key columns: keys are placed on this grid (see shared/keyboard.js) */
.kbd .row {
  display: grid;
  grid-template-columns: repeat(20, minmax(0, 1fr));
  column-gap: 2px;
  min-height: 0;
}

.kbd button {
  position: relative;
  overflow: hidden;
  container-type: inline-size;   /* for the codes (below) */
  min-width: 0;
  margin: 0 1px;   /* with the 2px column gap: 4px between keys */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0;
  border: 1px solid var(--wire);
  background: color-mix(in srgb, var(--paper) 4%, var(--bakelite));
  color: var(--paper);
  touch-action: none;
}

.kbd b {
  font-size: var(--fs-m);
  line-height: 1;
}

/* each key's code, tiny, under the letter */
.kbd small {
  font-size: 0.55rem;
  line-height: 1;
  letter-spacing: 0.05em;
  color: var(--graphite);
  white-space: nowrap;
}

.signal .kbd small .dot  { color: var(--dot); }
.signal .kbd small .dash { color: var(--dash); }

.kbd .k-layout b {
  font-size: var(--fs-s);
}

/* a key that would type something other than it says (+ with
   prosigns on, <AR> with them off: shared/keyboard.js): grey, idle,
   and its code grey too, even with the signal's colours on */
.kbd button.off,
.fan .item.off {
  color: var(--wire);
  border-style: dashed;
  cursor: default;
}
.kbd button.off small span,
.fan .item.off small span { color: var(--wire) !important; }

/*
 * Codes fit their key: each key measures its own width (a size
 * container) and a code of --len marks takes at most that, so
 * short codes stay full size and $ (7 marks) shrinks just enough.
 * (A monospace mark is about 0.6em wide.)
 */
.kbd small[style*="--len"] {
  font-size: min(0.55rem, calc(88cqw / (var(--len) * 0.62)));
  letter-spacing: 0;
}

/* keys that hold more (long-press): a tick in the corner. Letters hold
   their digits / symbols, 123 / ABC the layouts menu */
.kbd .more::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 4px;
  height: 4px;
  border-top: 1px solid var(--graphite);
  border-right: 1px solid var(--graphite);
}

/* an output's list, long-pressed open (station/layer.js): like the fan */
.quick-list {
  position: fixed;
  z-index: 15;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  max-width: calc(100vw - 12px);
  padding: 3px;
  background: var(--bakelite);
  border: 1px solid var(--paper);
  font-size: var(--fs-s);
}

.quick-list button {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  border: 0;
  padding: 0.45rem 0.6rem;
  color: var(--graphite);
  background: transparent;
}

.quick-list button.on {
  background: var(--paper);
  color: var(--bakelite);
}

/* an unsure letter's readings (station/tape.js): a column, the likeliest
   first, each its letter, its marks and how likely */
.quick-list.readings { flex-direction: column; flex-wrap: nowrap; }
.readings button {
  display: grid;
  grid-template-columns: 2ch auto 4ch;
  gap: 1.2ch;
  align-items: baseline;
  text-align: left;
}
.readings .marks { letter-spacing: 0.1ch; font-weight: 700; }
.readings button.on .marks span { color: inherit; }
.readings .odds { text-align: right; font-size: var(--fs-xs); }

/* the long-press fan */
.fan {
  position: fixed;
  z-index: 15;
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--bakelite);
  border: 1px solid var(--paper);
  user-select: none;
  -webkit-user-select: none;
}

.fan .item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 2.6rem;
  padding: 0.45rem 0.3rem;
  color: var(--paper);
}

.fan .item b {
  font-size: var(--fs-m);
  line-height: 1;
}

.fan .item small {
  font-size: 0.6rem;
  line-height: 1;
  color: var(--graphite);
  white-space: nowrap;
}

.signal .fan small .dot  { color: var(--dot); }
.signal .fan small .dash { color: var(--dash); }

.fan .item.on {
  background: var(--paper);
  color: var(--bakelite);
}

.fan .item.on small,
.fan .item.on small span {
  color: var(--bakelite) !important;
}

.kbd .pressed {
  background: var(--key-lit);
  color: var(--bakelite);
}

.kbd .pressed small,
.kbd .pressed small span {
  color: var(--bakelite) !important;
}

/* the (i) in the Z row's empty start: a ring, not a key */
.kbd .kbd-info {
  justify-self: center;
  align-self: center;
  width: 1.35rem;
  height: 1.35rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--graphite);
  border-radius: 50%;
  background: transparent;
  color: var(--graphite);
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1;
  overflow: visible;
}


/*
 * ============================================================
 * POPUPS
 * ============================================================
 *
 * Framed boxes over the page: the popups (privacy, misheard, the lamp's
 * warning, the about card), the share menu, the paste bubble, the toast.
 */

/* a small framed popup, centred over the page */
.popup {
  position: fixed;
  z-index: 14;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(20rem, calc(100vw - 2rem));
  padding: 1.1rem 1rem 0.8rem;
  border: 1px solid var(--graphite);
  background: var(--bakelite);
  box-shadow: 0 0 0 100vmax color-mix(in srgb, var(--bakelite) 60%, transparent);
  font-size: var(--fs-s);
  line-height: 1.45;
}

.popup .frame-label {
  left: 0.8rem;
}

.popup p + p {
  margin-top: 0.6rem;
}

/* cut numbers: each digit's marks, the ones the cut drops greyed,
   the row for the character showing in brass */
.cut-chart {
  margin: 0.6rem 0;
  font-size: var(--fs-s);
  line-height: 1.5;
}
.cut-chart .cut-row { display: block; color: var(--graphite); }
.cut-chart .cut-row.here { color: var(--brass); }
.cut-chart .dot,
.cut-chart .dash { color: var(--paper); }
.cut-note { color: var(--graphite); font-size: var(--fs-xs); }

/* a prosign or word, explained: its marks big, then what it is and
   what it means (a Q code both ways) */
.word-pop .word-marks { font-size: var(--fs-m); font-weight: 700; letter-spacing: 0.15em; }
.word-pop .word-kind { color: var(--graphite); font-size: var(--fs-xs); }
.word-pop .word-line { margin-top: 0.3rem; }
.word-pop .word-line b { color: var(--paper); }
.word-pop #word-means + p { margin-top: 0.6rem; }

/* the same, under the (i)'s card, for the word the letter ends */
.about-term { margin-top: 0.7rem; padding-top: 0.6rem; border-top: 1px dashed var(--wire); }
.about-term .about-term-title { color: var(--paper); font-weight: 700; }
.about-term .word-kind { color: var(--graphite); font-size: var(--fs-xs); }
.about-term .word-line { margin-top: 0.3rem; }
.about-term .word-line b { color: var(--paper); }

/* the about column's parts, a switch each, with what it is beside it */
.about-parts { list-style: none; margin: 0.6rem 0; padding: 0; color: var(--graphite); font-size: var(--fs-xs); }
.about-parts li + li { margin-top: 0.35rem; }
.about-parts .check { display: inline-block; min-width: 9ch; }

/* the report, as it would be copied: scrolls if long, wraps if wide */
.report-text {
  margin: 0.6rem 0 0;
  max-height: min(16rem, 50dvh);
  overflow: auto;
  padding: 0.5rem 0.6rem;
  border: 1px dashed var(--wire);
  color: var(--graphite);
  font-size: var(--fs-xs);
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* marks named in a popup's text take the dot / dash colours */
.signal .popup .dot  { color: var(--dot); }
.signal .popup .dash { color: var(--dash); }
/* (after the colours: a mark the cut drops is grey in any colour) */
.popup .cut-chart .gone { color: var(--wire); }

.popup .warn {
  color: var(--brass);
}

.popup .fast {
  color: var(--dot);
}

/* the profile: the callsign, then the counts in two columns of
   word and number, the letters on rows of their own

     letters   310    words    52
     most      E T A I N           */
/* taller than a short phone: the contents scroll inside, the label
   and the × stay on the frame */
.profile-body {
  max-height: calc(100dvh - 4rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.profile-call {
  display: flex;
  align-items: center;
  gap: 1ch;
  color: var(--graphite);
}

.profile-call input {
  flex: 1;
  min-width: 0;
  padding: 0.2rem 0.4rem;
  border: 0;
  border-bottom: 1px solid var(--wire);
  background: transparent;
  color: var(--paper);
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.profile-call input::placeholder {
  color: var(--wire);
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.profile-call input:focus-visible {
  outline: none;
  border-bottom-color: var(--brass);
}

.profile-pop .profile-note {
  margin-top: 0.4rem;
  color: var(--graphite);
  font-size: var(--fs-xs);
}

.profile-pop .profile-since {
  margin-top: 0.9rem;
  color: var(--graphite);
}

.profile-stats {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  gap: 0.15rem 1ch;
  margin-top: 0.35rem;
}

.profile-stats dt { color: var(--graphite); }
.profile-stats dd { margin: 0; font-variant-numeric: tabular-nums; }
.profile-stats dd.wide { grid-column: 2 / -1; letter-spacing: 0.1em; }

/* wear: the keys as chips (the shown one in paper), and the key
   drawn below, worn in brass (js/station/wear.js) */
.profile-wear { margin-top: 0.9rem; }
.profile-wear .profile-since { margin-top: 0; }

.wear-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.wear-keys:empty { display: none; }

.wear-keys [aria-checked="true"] {
  border-color: var(--paper);
  color: var(--paper);
}

/* the key drawn beside its count, in a box of its own whatever the
   key's shape (a tall dit, a wide side key) */
.wear-show {
  display: flex;
  align-items: center;
  gap: 1ch;
  margin-top: 0.5rem;
}

.wear-show .profile-note { margin-top: 0; }

.wear-canvas {
  display: block;
  flex: none;
}

.wear-canvas[hidden] { display: none; }

/* copy practice: the Koch characters so far, the newest in paper
   (the one being learned), between − and + */
.profile-practice {
  margin-top: 0.9rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--wire);
}

.profile-practice .profile-since { margin-top: 0; }

.koch-row {
  display: flex;
  align-items: center;
  gap: 1ch;
  margin-top: 0.4rem;
}

.koch-row .quiet { align-self: center; }

.koch-set {
  flex: 1;
  color: var(--graphite);
  letter-spacing: 0.15em;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.koch-set .new { color: var(--paper); }

.popup .koch-go {
  margin-top: 0.6rem;
  background: transparent;
}

.koch-row .quiet:disabled { opacity: 0.5; cursor: default; }

.popup .actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.9rem;
}

.popup .actions button {
  background: transparent;
}

.quiet {
  align-self: flex-start;
  border-color: var(--wire);
  color: var(--graphite);
  font-size: var(--fs-xs);
  padding: 0.2rem 0.6rem;
}

#lamp-go,
#report-copy {
  border-color: var(--paper);
  color: var(--paper);
}

.popup .popup-clear {
  margin-top: 0.8rem;
  background: transparent;
}

.popup .popup-clear.armed {
  border-color: var(--brass);
  color: var(--brass);
}

.popup .popup-clear:disabled {
  opacity: 0.5;
  cursor: default;
}

.popup .close,
.share-menu .close {
  position: absolute;
  top: 0.1rem;      /* the same at rest and on hover, or it jumps */
  right: 0.15rem;
  color: var(--graphite);
  font-size: var(--fs-s);
}

/* the small (i): a ringed letter, drawn so it looks the same everywhere */
.privacy .info,
.notice .info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35em;
  height: 1.35em;
  margin-left: 0.5ch;
  padding: 0;
  border: 1px solid var(--graphite);
  border-radius: 50%;
  background: transparent;
  color: var(--graphite);
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1;
  vertical-align: -0.2em;
}

.privacy-open[aria-expanded="true"] {
  border-color: var(--paper);
  color: var(--paper);
}

.share-menu {
  position: fixed;
  z-index: 10;
  top: var(--share-top, 3rem);   /* set on open: just under the share button */
  right: max(0.75rem, calc((100vw - 520px) / 2 + 0.75rem));
  width: min(20rem, calc(100vw - 1.5rem));
  padding: 1rem 0.9rem 0.7rem;
  background: var(--bakelite);
  border: 1px solid var(--graphite);
  box-shadow: 0 0 0 100vmax color-mix(in srgb, var(--bakelite) 55%, transparent);   /* dims the page behind */
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: var(--fs-s);
}

.share-menu .frame-label {
  left: 0.8rem;
}

.share-menu .rows {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.share-menu .rows + .rows {
  border-top: 1px dashed var(--wire);
  padding-top: 0.5rem;
}

.share-menu button {
  display: flex;
  justify-content: space-between;
  gap: 1ch;
  width: 100%;
  border: 0;
  padding: 0.35rem 0.2rem;
  text-align: left;
  background: transparent;
  color: var(--paper);
}

.share-menu button > span:first-child {
  flex: none;
  white-space: nowrap;
}

/* under copy link: a checkbox, the link with your settings */
.share-menu .share-with {
  display: flex;
  align-items: center;
  gap: 0.6ch;
  padding: 0 0.2rem 0.3rem;
  color: var(--graphite);
  font-size: var(--fs-xs);
  cursor: pointer;
}
.share-menu .share-with:has(input:checked) { color: var(--paper); }
.share-menu .share-with > span:not(.check):not(.peek) { flex: none; white-space: nowrap; }
.share-menu .share-with .peek { margin-left: auto; }
.share-menu .share-with:has(input:disabled) { color: var(--wire); cursor: default; }
@media (hover: hover) {
  .share-menu .share-with:not(:has(input:disabled)):hover { color: var(--brass); }
}

.share-menu .peek {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--graphite);
}

.share-menu .saves {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
}

.share-menu .saves .lead {
  color: var(--graphite);
  margin-right: 0.4rem;
}

.share-menu .saves button {
  width: auto;
  border: 1px solid var(--wire);
  padding: 0.25rem 0.6rem;
}

/* in the share menu, under everything */
.share-menu .privacy {
  margin-top: 0.2rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--wire);
  font-size: var(--fs-xs);
  line-height: 1.5;
  color: var(--graphite);
}

.share-note {
  min-height: 1.2em;
  color: var(--brass);
  font-size: var(--fs-xs);
}

/* the wait lamp: a small brass light keying AS while something's made */
.wait-lamp {
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  margin-right: 0.3em;
  border-radius: 50%;
  border: 1px solid var(--wire);
  vertical-align: -0.05em;
}

.wait-lamp.lit {
  background: var(--brass);
  border-color: var(--brass);
  box-shadow: 0 0 6px color-mix(in srgb, var(--brass) 70%, transparent);
}

.wait-label { color: var(--graphite); }

/*
 * ============================================================
 * AUXILIARY PAGES
 * ============================================================
 *
 * The waiting screen, the 404 page (and any other error page) are
 * one skeleton: the station's own shape, its parts at rest, keying a
 * short message: waiting, over and over for as long as it takes; an
 * error, once, as the page loads.
 *
 *   dot-da.sh                         (◯)    the header: home, profile
 *   ┌──────────────────────────────────┐
 *   │                                  │
 *   │        .... . / ....- - ....-    │    the message, centred, as the
 *   │        <HH>      4    0    4     │    tape plays it back: marks lit
 *   │                                  │    as they're keyed, a letter
 *   └──────────────o⁄──────────────────┘    white once sent (the newest
 *                                            underlined); the edge and
 *              error 404                     the switch key with it
 *        Nothing for you here.               the note, where the player
 *     back to the station · the reference    and the keys would be
 *
 * The switch is a link home. 404.html (and the like) key with
 * js/shared/skeleton.js; the waiting screen (#waiting in index.html, and its demo
 * wait.html) keys AS by the CSS alone, so it shows even when the
 * scripts never run.
 */

/* the page: the station's column (body.tx gives the width and padding) */
.aux-page {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.aux-page .tx-top .home {
  color: var(--paper);
  font-size: var(--fs-m);
  font-weight: 700;
  text-decoration: none;
}
.aux-page .profile { cursor: default; }

/* the box: no tree column, the message in the middle */
.aux-station .aux-field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 1.2rem 1.6rem;
}
.aux-field .line {
  width: 100%;   /* the field's width, as on the tape (shrunk to fit, a lone letter's marks wrapped) */
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 0.9rem 0;
}

/* the status number ends its line (skeleton.js) */
.aux-field .line .break { flex-basis: 100%; height: 0; }

/* the switch: home */
a.switch { text-decoration: none; }

/* where the player and the keys would be: the note (or nothing),
   so the box is the size it is on the station */
.aux-note {
  flex: none;
  height: calc(var(--input-h) + 6rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  text-align: center;
}
.aux-note h1 { font-size: var(--fs-l); font-weight: 700; color: var(--paper); }
.aux-note p { font-size: var(--fs-s); color: var(--graphite); }
.aux-note .aux-links { margin-top: 0.6rem; font-size: var(--fs-xs); }
.aux-note .aux-links a { color: var(--graphite); }
@media (hover: hover) {
  .aux-note .aux-links a:hover { color: var(--brass); background: transparent; }
}

/*
 * The waiting screen (index.html, #waiting): hidden for the first
 * second, so a normal start never shows it; if the page is stuck, it
 * covers the station with its skeleton until it isn't.
 */
.waiting {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  background: var(--bakelite);
  opacity: 0;
  visibility: hidden;
  animation: waiting-in 0.3s 1s forwards;
}
@keyframes waiting-in { to { opacity: 1; visibility: visible; } }
.waiting.wait-demo { animation: none; opacity: 1; visibility: visible; }   /* wait.html: shown at once */

/* over the station, the skeleton takes body.tx's place: the same column */
.waiting .aux-page {
  flex: none;
  max-width: calc(520px + 2 * var(--safe-x));
  height: 100dvh;
  padding: calc(0.75rem + var(--safe-top)) calc(0.75rem + var(--safe-x))
    calc(0.75rem + var(--safe-bottom));   /* the sides alike: centred on the glass (base.css --safe-x) */
}

/*
 * AS (.-..., "wait"), by the CSS alone, at 20 wpm (a 60 ms unit):
 * two units' rest, the marks, then a long rest with the letter lit,
 * and round again.
 *
 *   __ ▮ ▮▮▮ ▮ ▮ ▮ ______________     2 + 11 + 12 = 25 units, 1.5 s
 *      8 16  32 40 48 %  ┃ 52 %: AS sent, underlined
 */
.aux-wait .line .m span { animation: 1.5s step-end infinite; }
.aux-wait .line .m span:nth-child(1) { animation-name: as-1; }
.aux-wait .line .m span:nth-child(2) { animation-name: as-2; }
.aux-wait .line .m span:nth-child(3) { animation-name: as-3; }
.aux-wait .line .m span:nth-child(4) { animation-name: as-4; }
.aux-wait .line .m span:nth-child(5) { animation-name: as-5; }
@keyframes as-1 { 0% { opacity: 0.25; } 8%  { opacity: 1; } }
@keyframes as-2 { 0% { opacity: 0.25; } 16% { opacity: 1; } }
@keyframes as-3 { 0% { opacity: 0.25; } 32% { opacity: 1; } }
@keyframes as-4 { 0% { opacity: 0.25; } 40% { opacity: 1; } }
@keyframes as-5 { 0% { opacity: 0.25; } 48% { opacity: 1; } }

.aux-wait .line .p { animation: as-sent 1.5s step-end infinite; }
.aux-wait .line .p .n {   /* the name, not the space before it (as .landed's) */
  text-decoration: underline;
  text-underline-offset: 4px;
  animation: as-under 1.5s step-end infinite;
}
@keyframes as-sent {
  0%  { opacity: 0.25; }
  52% { opacity: 1; }
}
@keyframes as-under {
  0%  { text-decoration-color: transparent; }
  52% { text-decoration-color: currentColor; }
}

.aux-wait .aux-station { animation: as-lit 1.5s step-end infinite; }
.aux-wait .switch .arm { animation: as-arm 1.5s step-end infinite; }
.aux-wait .switch .led { animation: as-led 1.5s step-end infinite; }
@keyframes as-lit {
  0%, 12%, 28%, 36%, 44%, 52% { border-color: var(--wire); box-shadow: none; }
  8%, 16%, 32%, 40%, 48% {
    border-color: var(--brass);
    box-shadow: 0 0 0 1px var(--brass), 0 0 18px color-mix(in srgb, var(--brass) 45%, transparent),
      inset 0 0 28px color-mix(in srgb, var(--brass) 18%, transparent);
  }
}
@keyframes as-arm {
  0%, 12%, 28%, 36%, 44%, 52% { transform: rotate(-30deg); }
  8%, 16%, 32%, 40%, 48% { transform: rotate(0deg); }
}
@keyframes as-led {
  0%, 12%, 28%, 36%, 44%, 52% { fill: transparent; }
  8%, 16%, 32%, 40%, 48% { fill: var(--brass); }
}

@media (prefers-reduced-motion: reduce) {
  .aux-wait .line .m span,
  .aux-wait .line .p,
  .aux-wait .line .p .n,
  .aux-wait .aux-station,
  .aux-wait .switch .arm,
  .aux-wait .switch .led { animation: none; }
  .aux-wait .line .m span,
  .aux-wait .line .p { opacity: 1; }
}

/* the long-press bubble */
.paste-bubble {
  position: fixed;
  z-index: 12;
  transform: translate(-50%, calc(-100% - 12px));
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--paper);
  background: var(--paper);
  color: var(--bakelite);
  font-size: var(--fs-s);
}

.paste-bubble::after {          /* the little pointer underneath */
  content: "";
  position: absolute;
  left: 50%;
  bottom: -11px;
  margin-left: -6px;
  border: 6px solid transparent;
  border-top-color: var(--paper);
}

/* a long-press on a message: copy it (as the quick lists: slide, let go) */
.copy-bubble {
  position: fixed;
  z-index: 12;
  transform: translate(-50%, calc(-100% - 16px));
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--bakelite);
  border: 1px solid var(--paper);
  font-size: var(--fs-s);
  white-space: nowrap;
}
.copy-bubble[hidden] { display: none; }
.copy-bubble button {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  border: 0;
  padding: 0.45rem 0.7rem;
  color: var(--graphite);
  background: transparent;
}
.copy-bubble button.on { background: var(--paper); color: var(--bakelite); }
.copy-bubble button:disabled { color: var(--wire); }
@media (hover: hover) {
  .copy-bubble button:not(.on):not(:disabled):hover { color: var(--brass); }
}

/* a short message (nothing to paste, …) under the header */
/* placed in the middle of the message (shared/dom.js toast) */
.toast {
  position: fixed;
  z-index: 12;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--wire);
  background: var(--bakelite);
  color: var(--brass);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

/* with something to do about it (a link's settings: keep) */
.toast.acts {
  white-space: normal;
  width: max-content;
  max-width: min(22rem, 90vw);
  text-align: center;
  line-height: 1.6;
}
.toast-act {
  border: 1px solid var(--brass);
  background: transparent;
  color: var(--paper);
  padding: 0 0.6rem;
  margin-left: 0.4rem;
  font: inherit;
  cursor: pointer;
}
@media (hover: hover) {
  .toast-act:hover { background: var(--brass); color: var(--bakelite); }
}

/* the about card: wider than the other popups, scrolling inside */
.about-pop { width: min(34rem, calc(100vw - 1.5rem)); }

.about-pop .about-card {
  max-height: min(74vh, 40rem);
  overflow: auto;
  margin: 0.4rem 0 0;
}

.about-pop .about-more { margin: 0.6rem 0 0; font-size: var(--fs-xs); }
.about-pop .about-more a { color: var(--graphite); text-decoration: none; }


/*
 * ============================================================
 * THE SIGNAL LAMP
 * ============================================================
 *
 * The whole screen, black and paper, while a message plays.
 */

/*
 * Signal lamp: the whole screen, black ↔ paper. True black between
 * flashes, so an OLED screen switches its pixels off; lit, the dark
 * theme's paper whatever the theme (a lamp lights up), dimmed toward
 * black with the light level.
 */
.lamp {
  --lamp-off: #000;
  --lamp-on: #e9e3d5;
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2rem 1.25rem;
  background: var(--lamp-off);
  color: color-mix(in srgb, var(--lamp-on) 16%, var(--lamp-off));    /* ghost text, barely there */
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.lamp.on {
  --lit: color-mix(in srgb, var(--lamp-on) 85%, var(--lamp-off));   /* just under full: the phone's brightness does the rest */
  background: var(--lit);
  color: color-mix(in srgb, var(--lamp-off) 14%, var(--lit));
}

.lamp .ghost {
  text-align: center;
  overflow: hidden;
}

.lamp .ghost-morse {
  font-size: clamp(1.4rem, 7vw, 2.6rem);
  font-weight: 700;
  line-height: 1.3;
  word-spacing: 0.4em;
  overflow-wrap: anywhere;
}

.lamp .ghost-text {
  margin-top: 1rem;
  font-size: clamp(1rem, 5vw, 1.6rem);
  letter-spacing: 0.3em;
}

.lamp .lamp-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(1rem + var(--safe-bottom));
  text-align: center;
  font-size: var(--fs-xs);
}


/*
 * ============================================================
 * THE EYE, BEYOND THE TAPE
 * ============================================================
 */

.redact,
.redact * {
  color: transparent !important;
  pointer-events: none;
  cursor: default;
}

.local .redact { background: var(--bar) !important; border: 0; border-radius: 1px; }
.about .redact { margin-left: 0.35rem; margin-right: 0.35rem; }
.about-marks.redact i { align-self: stretch; }

/* one shape for any name, the size of the tallest (NOVEMBER's
   stair): its length gives nothing away */
.about-name.redact,
.about-prosign.redact {
  display: block;
  align-self: stretch;
  width: auto;
  height: calc(8 * 0.56em + 2 * 0.3em + 0.45em);
  font-size: var(--fs-s);
  background: var(--bar);
  border-radius: 1px;
}

.about-name.redact > * { display: none; }

/* the marks, the cut and ~: bars the column's full width */
.about-marks.redact { align-self: stretch; gap: 0; }
.about-marks.redact i { width: 100% !important; background: var(--bar) !important; }

.about-cut.redact,
.about-heard.redact { align-self: stretch; align-items: stretch; }

.about-cut.redact b,
.about-heard.redact b { display: block; background: var(--bar); border-radius: 1px; }
.about-heard.redact b + b { margin-top: 0.2em; }
.redact .about-label { color: var(--graphite) !important; text-align: center; }   /* the titles stay */

/* the counts: the numbers go, the words stay */
.stats .n.redact {
  display: inline-block;
  min-width: 2ch;
  background: var(--bar);
  border-radius: 1px;
  line-height: 1.05;
}


/*
 * ============================================================
 * ONE LANGUAGE FOR WHAT CAN BE TOUCHED
 * ============================================================
 *
 *   grey     idle, or off
 *   brass    under the pointer, or in focus: this will act
 *   paper    on, or chosen
 *
 * Hover only where there's a real pointer (no sticky hover on a
 * phone). A key held down gets a brass edge too, as bright as the
 * light level (like the lit keys); hover and focus stay full brass
 * so they can always be seen.
 */
@media (hover: hover) {
  /* text and icons: brass, never a fill */
  :root .tx :is(#paste, #share-toggle, #profile, .tray-toggle, .tab, #chips-more, .outputs button, .chip, .flag-word,
                .input-mode, .deck button, .rx-link, .rx-isolate, .rx-medium, .edge-toggle, #local button, .about a, .about button,
                .marker .eye, .entry .x, .tape-head button, .player button,
                .share-menu button, .popup .close, .popup .actions button, .quiet, .paste-bubble,
                .about-pop .about-card a, .about-pop .about-more a, .stats:not(:empty), .quick-list button:not(.on)):not(:disabled):not(.secret):hover {
    color: var(--brass);
    background: transparent;
  }
  /* and the parts inside them with a colour of their own */
  :root .tx .about a:hover b,
  :root .tx .about button:hover :is(b, .stress) { color: var(--brass); }
  :root .tx .about .about-marks:hover i { background: var(--brass); }

  :root .tx .station .switch:hover svg { color: var(--brass); }

  /* framed: the frame too */
  /* the input switch: the side a press would turn on */
  :root .tx .input-mode:hover .side:not(.on) { color: var(--brass); }
  :root .tx .tab:not([aria-selected="true"]):hover::before,
  :root .tx .tab:not([aria-selected="true"]):hover::after,
  :root .tx .holds:hover::after { border-color: var(--brass); }
  :root .tx .line .c.unsure .p.takes:hover { color: var(--brass); }
  :root .tx .chip:hover { border-color: var(--brass); }
  :root .tx .chip:hover .chip-name { color: var(--brass); }
  :root .tx :is(.popup .actions button, .paste-bubble):not(:disabled):hover {
    border-color: var(--brass);
  }
  :root .tx .send:not(:disabled):hover {
    border-color: var(--brass);
    color: var(--brass);
  }
  /* every (i) the same: a brass ring, no fill */
  :root .tx :is(.info, .kbd-info):hover {
    background: transparent;
    border-color: var(--brass);
    color: var(--brass);
  }

  /* the tree's letters: their colours at rest, brass to the pointer */
  :root .tx #tree .lbl:not(.blank):hover { color: var(--brass); cursor: pointer; }
  /* the keys */
  :root .tx #pad .key:hover,
  :root .tx #kbd button[data-k]:not(.off):hover { border-color: var(--brass); }
  /* settings: the list (text, underline, chevron) and the [ ] */
  :root .tx .switches label:has(select:not(:disabled)):hover select { color: var(--brass); border-bottom-color: var(--brass); }
  :root .tx .switches label:has(select:not(:disabled)):hover::after { border-color: var(--brass); }
  :root .tx .flag:hover .check::before { color: var(--brass); }
}

/* held down: a brass edge, as bright as the station's own lights */
.tx .key.pressed,
.tx .kbd .pressed {
  border-color: color-mix(in srgb, var(--brass) calc(var(--ui-glow) * 100%), var(--wire));
}



/*
 * ============================================================
 * SHORT SCREENS
 * ============================================================
 *
 * Half a phone in split screen, or a phone on its side: 440px tall
 * or less. The keys are what you touch, so they keep what room
 * there is: the margins and gaps around everything else tighten,
 * and the input area has the difference (--rest, at the top).
 * Picked by the height alone, so dragging the split's divider
 * resizes things where they are; nothing trades places.
 *
 * Shorter than everything at its least (about 365px: a third of a
 * phone, or less), the page scrolls rather than cut the keys off below.
 */
@media (max-height: 440px) {
  body.tx {
    --rest: calc(16.75rem - 1.35 * var(--fs-xs));   /* less the counts' second row (below):
                                                       it goes to the keys */
    padding-top: calc(0.5rem + var(--safe-top));
    padding-bottom: calc(0.5rem + var(--safe-bottom));
    gap: 0.4rem;
  }
  .controls { margin-top: 0.4rem; }
  .panel, .slot { gap: 0.3rem; }

  /* the counts on one row, a pair either side of the switch; the row
     they free goes to the keys (--rest, above), the message keeping
     its line

       7 chars  2 words      o/      13 dits  9 dahs            */
  .stats {
    grid-template-columns: repeat(4, auto);
    min-height: 1.35em;
  }
  .station { min-height: calc(0.75rem + 1.1rem + 2.4 * var(--fs-m) + 0.75rem + 1.35 * var(--fs-xs) + 3px); }
  .stats .n:nth-of-type(2) { margin-left: 1.5ch; }
  .tree-edge * { cursor: pointer; }   /* all of it is one button (station/layer.js) */
  .key.side { font-size: var(--fs-m); }   /* ˽ / ⌫ ↵ inside their keys */
}

@media (max-height: 365px) {
  body.tx { overflow-y: auto; }
}
