/*
 * A bundled monospace, last before the system's generic one: a
 * small subset of JetBrains Mono (SIL OFL 1.1, fonts/OFL.txt) with
 * the letters, the tree's pipes, the blocks and the arrows. Phones
 * with none of the fonts named before it (Android, mostly) would
 * otherwise draw pipes and blocks from fonts of other widths, and
 * the tree would come apart. Where Menlo or Consolas exist, it's
 * never downloaded.
 */
@font-face {
  font-family: "dot-dash mono";
  src: url("../fonts/dot-dash-mono-Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "dot-dash mono";
  src: url("../fonts/dot-dash-mono-Bold.woff") format("woff");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ============================================================
 * dot-da.sh — bakelite & brass
 * ============================================================
 *
 * The palette comes from a telegraph key: a black Bakelite
 * base, brass contacts, and the red/blue of dot and dash.
 * One typeface family (the system's monospace), so nothing
 * to download and box-drawing lines that join up.
 *
 *   ┌─ label ─────────┐   every section is a "frame": a ruled
 *   │                 │   box with its name in the top border
 *   └─────────────────┘
 */

:root {
  --bakelite: #1c1916;   /* background */
  --paper:    #e9e3d5;   /* text */
  --graphite: #8c857a;   /* secondary text */
  --wire:     #4a443c;   /* lines, dimmed tree parts */
  --brass:    #d6a650;   /* focus and cursor only */

  --dot:  #e2604f;
  --dash: #6ea8e0;
  --dim:  #4a443c;

  --mono: Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", "dot-dash mono", monospace;

  color-scheme: dark;
}

/*
 * The light theme ("invert" in /tx settings): the same instrument
 * printed on paper. Kept after the dark palette above (the preview
 * card's worker reads the first one).
 */
:root.light {
  --bakelite: #ebe5d7;
  --paper:    #1f1b17;
  --graphite: #6d665b;
  --wire:     #c2baab;
  --brass:    #9a6a12;

  --dot:  #c4412e;
  --dash: #2b69ad;
  --dim:  #c2baab;

  color-scheme: light;
}

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

html {
  background: var(--bakelite);
}

body {
  max-width: calc(880px + 2 * var(--safe-x));
  margin: 0 auto;
  padding: calc(2rem + var(--safe-top)) calc(1rem + var(--safe-x)) calc(4rem + var(--safe-bottom));
  background: var(--bakelite);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.5;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

/* the fill on hover is this site's pages', not the station's: it has
   its own language (grey, brass to the pointer, paper when on; station.css).
   :where keeps the selector's weight as it was */
:where(body:not(.tx)) a:hover {
  background: var(--paper);
  color: var(--bakelite);
  text-decoration: none;
}

:focus-visible {
  outline: 1px dashed var(--brass);
  outline-offset: 3px;
}

::selection {
  background: var(--brass);
  color: var(--bakelite);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}


/* ============================================================
 * HEADER
 * ============================================================ */

/*
 * The bar, on every page (js/shared/nav.js): the name and the trail to here,
 * the last crumb the page's heading; share and the profile at the right.
 *
 *   dot-da.sh / REF / ALPHABET / K ▾                  share  (◯)
 *
 * The name is paper and bold; the crumbs on the way grey, brass to the
 * pointer, paper while their menu is open; where you are is paper, on
 * a dotted line, with a chevron: it opens the pages beside it.
 */
/*
 * One bar for every page, whatever the page's own width, and it's the
 * station's: the station is the home page, so its bar lines up with
 * its box, and every other page keeps that bar where it was. Key hero
 * is a little wider, the reading pages 880px; the bar stays the
 * station's width, centred on the screen (body is, so its middle is
 * the screen's), as far from the top. Going from page to page, the
 * name, the crumbs, share and the profile stay put.
 *
 *   phone     │▏dot-da.sh / REF ▾       share (◯)▕│     0.75rem in, as the station
 *   desktop   │   ┌ dot-da.sh / REF ▾ … share (◯) ┐   │  496px, the station's box
 *             │ the reading page, 880px, under it   │
 */
:root {
  /* the page's width, less a gutter each side: cqw, not vw, so a
     desktop's scrollbar isn't counted as room (vw includes it) */
  container-type: inline-size;
  /*
   * The safe areas: what a phone's bars and notch cover, when the page
   * runs under them (viewport-fit=cover, on every page: a page without
   * it, opened from one with it, made an installed app change its
   * window, and the station came back a pixel off). 0 in a browser's
   * tab. The sides take the larger of the two, both of them, so on a
   * phone on its side the page stays in the middle of the glass, not
   * of what's left beside the notch:
   *
   *   ┌──┬────────────────────────────┬──┐
   *   │▓▓│        the page            │  │   ▓ the notch (--safe-x)
   *   └──┴────────────────────────────┴──┘     and as much again
   */
  --safe-x: max(env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bar-w: min(496px, calc(100cqw - 1.5rem - 2 * var(--safe-x)));
  --bar-top: calc(0.75rem + var(--safe-top));   /* from the top of the screen (the station's and Key hero's own padding) */
  /* (not scrollbar-gutter: it narrows the page where scrollbars float;
     so where they don't, a desktop's, a page that scrolls has its
     middle half a scrollbar to the left of the station's) */
}

.top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5ch;
  width: var(--bar-w);
  height: 2rem;
  margin-left: calc(50% - var(--bar-w) / 2);
  margin-right: calc(50% - var(--bar-w) / 2);
  margin-bottom: 2.5rem;
  flex: none;
  /* its own type, not the page's (the station's is a size up) */
  font-size: 15px;
  line-height: 1.5;
}

/* the reading pages start as high as the station, so the bar does too */
body:not(.tx, .hero):has(> .top) { padding-top: var(--bar-top); }

/*
 * And there it stays as they scroll (the station and Key hero don't
 * scroll): where it sits at rest, so it never moves, over the page's
 * colour across the whole screen, so what scrolls slides under it.
 * Once the page has moved, a rule under it (js/shared/nav.js .stuck).
 *
 *   ┌───────────────────────────────────────┐
 *   │   dot-da.sh / REF / K ▾     share (◯)  │  stuck
 *   ├───────────────────────────────────────┤  the rule, once scrolled
 *   │   … the page, going under it …         │
 */
body:not(.tx, .hero) > .top {
  position: sticky;
  top: var(--bar-top);
  z-index: 20;
}
body:not(.tx, .hero) > .top::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: calc(-1 * var(--bar-top));
  bottom: -0.6rem;
  /* the page's width, edge to edge: cqw (:root's), not vw, which counts
     a desktop's scrollbar and ran 8px past it (a sideways scroll) */
  left: calc(50% - 50cqw);
  right: calc(50% - 50cqw);
  border-bottom: 1px solid transparent;
  background: var(--bakelite);
  transition: border-color 0.15s;
}
body:not(.tx, .hero) > .top.stuck::before { border-bottom-color: var(--wire); }

/* (.top first: a page's own nav and h1 rules, prose.css's, stay out) */
.top .crumbs {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: inherit;
}

.top .crumbs ol {
  display: flex;
  flex-wrap: nowrap;   /* one line: what doesn't fit folds (js/shared/nav.js) */
  gap: 0;
  align-items: center;   /* each crumb centred on the bar's line: no baseline to shift when the script makes the heading a button (it moved the crumbs a pixel as the page loaded) */
  list-style: none;
  white-space: nowrap;
}

.crumbs li {
  display: flex;
  align-items: center;
  margin: 0;   /* (prose.css .notes li + li spacing isn't the bar's: see below) */
  min-width: 0;
  flex: none;
}

/* where you are gives way last: a long name ends in … (with a section
   after it, the heading stays whole: the section gives way, down to
   "#", then the crumbs before it fold) */
.crumbs li:last-child { flex: 0 1 auto; }
.crumbs li.section { flex: 0 100 auto; min-width: 5.5ch; }   /* "#" and its chevron, always */
.crumbs li:has(> h1) { flex: 0 0.01 auto; }   /* (gives way too, but last) */
.crumbs li.section .crumb-name { min-width: 0; }

.top .crumbs li + li { margin: 0; }

.crumbs li.folded,
.crumbs li[hidden] { display: none; }

/* the separator: a thin slash, a little taller than the letters */
.crumbs li + li::before {
  content: "";
  flex: none;
  width: 1px;
  height: 1.35em;
  align-self: center;
  margin: 0 1.1ch;
  background: var(--graphite);
  transform: rotate(20deg);
}

.crumbs .home {
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--paper);
}

/* the name, or on a narrow phone the logo (the switch, js/shared/nav.js):
   either one centred on the bar's line, out of the crumbs' baseline,
   so swapping one for the other moves nothing (on the baseline, the
   logo's foot sat on it: the logo high, the line taller, the crumbs
   pushed down) */
.crumbs li:first-child { align-self: center; }
.crumbs .home { display: flex; align-items: center; }
.crumbs .home-logo { display: none; width: 1.55rem; height: 1.55rem; }
.crumbs.tight .home { font-size: 0; }
.crumbs.tight .home-logo { display: block; }
/* the logo's lever is a slash already: no "/" after it (its room kept,
   so the crumb after it doesn't crowd it). After the fold's "…", or
   with no fold shown, whichever crumb comes first */
.crumbs.tight li:first-child + li::before,
.crumbs.tight li:first-child + li[hidden] + li::before { background: transparent; }

.top .crumbs h1 {
  min-width: 0;
  margin: 0;
  font: inherit;
}

/* a crumb: a link with no script, a button with it (js/shared/nav.js) */
.crumb,
.crumbs a[data-crumb],
.top .crumbs h1 {
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 1.5;
}

.crumb,
.crumbs a[data-crumb] {
  display: inline-flex;
  align-items: center;
  gap: 0.6ch;
  min-width: 0;
  padding: 0.15rem 0;
  border: 0;
  background: transparent;
  color: var(--graphite);
  text-decoration: none;
  cursor: pointer;
}

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

/* where you are: paper, on a dotted line */
.crumbs h1,
.crumbs h1 .crumb { color: var(--paper); }
.crumbs h1 .crumb-name,
.crumbs h1 > .crumb-name {
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px dotted var(--graphite);
  padding-bottom: 1px;
}
.crumbs h1 .crumb { max-width: 100%; }
/* in the button the name is a box of its own, centred with its dotted
   line under it: as much above, so its letters sit where they did
   before the script (they rose a pixel as the page loaded) */
.crumbs h1 .crumb .crumb-name { padding-top: 2px; }

/* the section you're reading (js/shared/nav.js): "#" and its name */
.crumbs li.section .crumb { max-width: 100%; }
.crumbs li.section .crumb-name {
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0;
}
.crumbs li.section .crumb-name[hidden] { display: none; }
.crumb-hash { flex: none; color: var(--brass); }

.crumb-chev {
  flex: none;
  width: 0.7em;
  height: 0.5em;
  color: var(--graphite);
}

@media (hover: hover) {
  .crumbs .home:hover,
  .crumb:hover,
  .crumb:hover .crumb-chev,
  .crumbs a[data-crumb]:hover { color: var(--brass); background: transparent; }
  .crumbs h1 .crumb:hover .crumb-name { border-bottom-color: var(--brass); }
}

/* the menu under a crumb (or share): the pages beside it, the one
   you're on paper; short names in a grid, long ones a column */
.crumb-menu {
  position: absolute;
  z-index: 30;
  /* one width for every menu, whatever's open in it (the widest, the
     abbreviations' grid, fits), so it never changes shape under you */
  width: min(16rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 5rem);   /* (js/shared/nav.js sets it to the room under the bar) */
  scrollbar-width: thin;
  scrollbar-color: var(--wire) transparent;
  overflow-y: auto;
  padding: 0.35rem 0;
  border: 1px solid var(--graphite);
  background: var(--bakelite);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-align: left;
}

.crumb-list { list-style: none; }

/* a page's own list look (prose.css: a dot before each) isn't the menu's */
.top .crumb-menu li {
  display: block;
  margin: 0;
  padding: 0;
  text-indent: 0;
}
.top .crumb-menu li::before { content: none; }

.crumb-list a,
.crumb-list button {
  display: flex;
  justify-content: space-between;
  gap: 2ch;
  width: 100%;
  padding: 0.26rem 0.9rem;
  border: 0;
  background: transparent;
  color: var(--graphite);
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
}

.crumb-list [aria-current] {
  color: var(--paper);
  text-decoration: underline dotted;
  text-underline-offset: 4px;
}

.crumb-list .rule {
  height: 0;
  margin: 0.4rem 0.9rem;
  border-top: 1px solid var(--wire);
}

.crumb-list.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(4.6ch, 1fr));
  width: auto;
  padding: 0 0.45rem;
}

.crumb-list.grid a {
  justify-content: center;
  padding: 0.26rem 0.2rem;
}

/* a page with pages under it: its link, then a chevron that opens them,
   in place and indented; it points right, and down while they're open */
.top .crumb-menu li.has-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}
.crumb-list .sub-toggle { align-items: center; }
.crumb-list .sub-toggle[aria-current] { color: var(--paper); }
.crumb-sub {
  width: 0.5em;
  height: 0.75em;
  transition: transform 0.15s;
}
.sub-toggle[aria-expanded="true"] { color: var(--paper); }
.sub-toggle[aria-expanded="true"] .crumb-sub { transform: rotate(90deg); }
.crumb-menu ul.sub {
  flex-basis: 100%;
  margin: 0 0 0.3rem 0.9rem;
  border-left: 1px solid var(--wire);
}
.crumb-menu ul.sub[hidden] { display: none; }
.crumb-list .peek {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
  color: var(--wire);
}

/* the sections' list: a long title (how it works' are questions) wraps
   in the menu's width, its lines close together, the rows apart */
.crumb-list.sections a {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
  padding-block: 0.35rem;
}

/* a menu's title (the sections': "on this page") */
.crumb-menu-title {
  margin: 0.1rem 0 0.35rem;
  padding: 0 0.9rem 0.35rem;
  border-bottom: 1px solid var(--wire);
  color: var(--graphite);
  font-size: 0.72rem;
}

.crumb-note {
  min-height: 0;
  padding: 0 0.9rem;
  color: var(--graphite);
  font-size: 0.72rem;
}
.crumb-note:empty { display: none; }

@media (hover: hover) {
  .crumb-list a:hover,
  .crumb-list button:hover { color: var(--brass); background: transparent; }
}

/* share and the profile, at the right of every bar */
.top .top-right {
  display: flex;
  flex: none;
  align-items: center;
  gap: 1.2ch;
}

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

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

@media (hover: hover) {
  .top .share-toggle:hover { color: var(--brass); background: transparent; }
}

.top .profile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  margin-right: -0.35rem;   /* its ring, not its tap room, at the edge */
  color: var(--graphite);
}

.top .profile svg {
  width: 1.2rem;
  height: 1.2rem;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.15rem;
  font-weight: 700;
  text-decoration: none;
}

.logo svg {
  color: var(--paper);
  overflow: visible;
}

@media (hover: hover) {
  .logo:hover svg { color: var(--brass); }   /* brass to the pointer, as everywhere */
}

/* the switch keys along with the message: lever drops shut, LED lights */
.logo .arm {
  transform-box: view-box;
  transform-origin: 16.02px 47.22px;
  transform: rotate(-30deg);
}

.logo.down .arm {
  transform: rotate(0deg);
}

.logo .led {
  fill: transparent;
}

.logo.down .led {
  fill: var(--brass);
}


/* ============================================================
 * FRAMES
 * ============================================================
 *
 * A ruled box with its name sitting in the top border.
 */

.frame {
  --frame-top: 1.75rem;    /* named: a prose page's label sits by them (prose.css) */
  --frame-side: 1.5rem;
  position: relative;
  border: 1px solid var(--wire);
  padding: var(--frame-top) var(--frame-side) 1.5rem;
  margin-top: 2.5rem;
}

.frame-label {
  position: absolute;
  top: -0.75em;
  left: 1rem;
  padding: 0 0.6ch;
  background: var(--bakelite);
  color: var(--graphite);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
}

/* a frame's way elsewhere, on its top edge at the right, as its label
   sits at the left:   ┌ about A ──────────── its page › ┐   */
.frame-corner {
  position: absolute;
  top: -0.75em;
  right: 1rem;
  padding: 0 0.6ch;
  background: var(--bakelite);
  color: var(--graphite);
  font-size: 15px;
  line-height: 1.5;
  text-decoration: none;
}
.frame-corner[hidden] { display: none; }
@media (hover: hover) { .frame-corner:hover { color: var(--brass); background: var(--bakelite); } }
.frame-corner:focus-visible { color: var(--brass); outline: 1px dashed var(--brass); outline-offset: 2px; }

/* by a section's heading, on hover: a brass # that copies its link
   (js/shared/nav.js), on the frame's top edge just left of the label,
   so the label never moves

     ─ # ┌ keying ─────────     */
.frame > .anchor {
  position: absolute;
  top: -0.75em;
  right: calc(100% - 1rem);
  padding: 0 0.4ch;
  background: var(--bakelite);
  color: var(--brass);
  font-size: 15px;
  line-height: 1.5;
  text-decoration: none;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.12s linear;
}
@media (hover: hover) {
  .frame:hover > .anchor { opacity: 1; }
  .frame > .anchor:hover { background: var(--bakelite); color: var(--brass); }
}
.frame > .anchor:focus-visible { opacity: 1; outline: 1px dashed var(--brass); outline-offset: 2px; }

/* graphite: unlinked nodes in the about card (overview.js) */
.empty {
  color: var(--graphite);
}

/* the way to the design notes, under the last frame */
.colophon {
  margin-top: 1.5rem;
  color: var(--graphite);
}

/* the reference's list of the characters' own pages: a quiet index
   under the chart, each character with room around it for a thumb

     A B C D E F G …
     1 2 3 4 5 6 7 8 9 0
     . , ? ! ' " ( ) & …                                          */
.pages {
  margin-top: 1.5rem;
  color: var(--graphite);
}
.pages p { margin: 0.25rem 0 0; max-width: none; }
.pages p.gathered { margin-top: 0.75rem; }   /* the pages that gather them (/ref/chart/ …) */
.pages a {
  display: inline-block;
  min-width: 1.5em;
  padding: 0.25em 0;
  text-align: center;
}


/* ============================================================
 * CONTROLS
 * ============================================================ */

button {
  font: inherit;
  color: var(--paper);
  background: transparent;
  border: 1px solid var(--paper);
  padding: 0.35rem 0.9rem;
  cursor: pointer;
}

:where(body:not(.tx)) button:hover {   /* (not the station's: see a:hover) */
  background: var(--paper);
  color: var(--bakelite);
}

/* option rows: plain words, [x] checkboxes, underlined menus */

.options {
  border: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.75rem;
  font-size: 0.9rem;
  color: var(--graphite);
}

.options-look {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--wire);
}

.check {
  position: relative;
  cursor: pointer;
  color: var(--paper);
}

.check input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.check::before {
  content: "[ ] ";
  white-space: pre;
  color: var(--graphite);
}

.check:has(input:checked)::before {
  content: "[x] ";
  color: var(--paper);
}

/* the box after its word, so a row of them lines up at the right:
     stroke [ ]       cut [x]                                      */
.check.box-after::before,
.check.box-after:has(input:checked)::before { content: none; }
.check.box-after::after {
  content: " [ ]";
  white-space: pre;
  color: var(--graphite);
}
.check.box-after:has(input:checked)::after {
  content: " [x]";
  color: var(--paper);
}

/* the box alone, its word above it (cards, on /ref):  cards
                                                        [ ]   */
.check.box-only::before { content: "[ ]"; }
.check.box-only:has(input:checked)::before { content: "[x]"; }

/* in /ref's option rows, the words grey like the menus' ("numbers",
   "layout"), the box paper when it's on: what's chosen is what's lit */
.options .check { color: var(--graphite); }

/* a switch that does nothing now (circles, with stroke off): struck
   through, its box wire, out of reach */
.check:has(input:disabled),
.morse-code .heading-row .check:has(input:disabled) { color: var(--wire); text-decoration: line-through; cursor: default; }
.check:has(input:disabled)::before,
.check:has(input:disabled)::after { color: var(--wire); }

.check:has(input:focus-visible) {
  outline: 1px dashed var(--brass);
  outline-offset: 3px;
}

.pick select {
  font: inherit;
  color: var(--paper);
  background: transparent;
  border: 0;
  border-bottom: 1px dotted var(--graphite);
  margin-left: 0.5ch;
  padding: 0 0.25ch;
  cursor: pointer;
}

.pick select option {
  background: var(--bakelite);
  color: var(--paper);
}


/* ============================================================
 * TREES
 * ============================================================
 *
 *   idle      everything in paper
 *   .live     playing: everything dims except the path
 *   .on       on the current path
 *   .landed   the character just finished
 *   .selected the character tapped or typed (stays lit)
 */

.tree {
  font-family: var(--mono);
  white-space: pre;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.1;
  width: fit-content;     /* centred as a diagram, scrolls if wider than the frame */
  max-width: 100%;
  margin: 1.75rem auto 0;
  padding-bottom: 0.4em;  /* room for "_" on the last row (the scroll box clips) */
  font-synthesis: none;   /* never fake a bold that changes widths */
}

.tree .lbl:not(.blank) {
  cursor: pointer;
}

.tree .blank {
  color: var(--dim);
}

/* a group's page: the way to its rows greyed, its rows lit (js/ref/main.js) */
.tree .off-row:not(.on) {
  color: var(--dim);
}

.tree span {
  transition: color 0.08s linear;
}

.tree.live span:not(.on):not(.legend) {
  color: var(--dim);
}

.tree .on,
.tree .root.on {
  color: var(--paper);
}

/*
 * Only text goes bold. Line characters stay regular: many
 * monospace fonts have no bold box-drawing glyphs, and the
 * fallback font is a different width, so lines would grow.
 */
.tree .lbl.on,
.tree .mark.on {
  font-weight: 700;
}

.tree .landed,
.tree .lbl.selected {
  background: var(--paper);
  color: var(--bakelite) !important;
}

.tree .legend {
  color: var(--graphite);
}

/* a moment's word over the part tapped: "copied", "soon" (the about
   column, the counts, the profile, a greyed key). One tip on top of everything
   (shared/dom.js flash): no neighbour covers it, no edge clips it */
.flash-tip {
  position: fixed;
  z-index: 1000;
  transform: translate(-50%, -50%);
  padding: 0.1rem 0.25rem;
  background: var(--bakelite);
  border: 1px solid var(--brass);
  color: var(--brass);
  font-size: var(--fs-xs);
  font-weight: 400;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
}

/* the settings gear, lit a moment: the setting that greyed a key is
   in there (shared/keyboard.js hint) */
[aria-controls="tray"].hint { animation: gear-hint 0.5s ease-in-out 2; }
@keyframes gear-hint { 50% { color: var(--brass); } }

/* signal colours: the path itself */
.signal .tree .on.dot,
.signal .tree .legend.dot   { color: var(--dot); }
.signal .tree .on.dash,
.signal .tree .legend.dash  { color: var(--dash); }

/* a lit junction lights only the elbow it was left by (core/tree.js
   ELBOW): the ┴ itself as if unlit, the ┘ drawn over it lit

     ┴  dim  +  ┘  lit  =  ┘ lit, its other arm dim                   */
.tree .on.elbow,
.signal .tree .on.elbow {
  position: relative;
  display: inline-block;   /* a line's box, not the font's: the ┘ over it sits on the ┴'s own baseline */
  color: inherit;
}
.tree.live .on.elbow,
.signal .tree.live .on.elbow { color: var(--dim); }
.tree .on.elbow::after {
  content: attr(data-elbow);
  position: absolute;
  left: 0;
  top: 0;
  color: var(--paper);
}
.signal .tree .on.elbow.dot::after  { color: var(--dot); }
.signal .tree .on.elbow.dash::after { color: var(--dash); }

/* one tree at a time, as the layout menu says (horizontal until
   js/ref/main.js has read it); a wide one scrolls sideways */
.tree-frame:not([data-layout="vertical"]) .tree-v,
.tree-frame[data-layout="vertical"] .tree-h { display: none; }

/* the canvas: as wide as the tree (the frame at most), with replay
   at its top left and expand at its top right. They ride on a row
   of no height that sticks to the top of the screen while the tree
   goes past, so they're there over a tall tree too

     ┌────────────────────────────┐
     │ ↻                        ⤢ │
     │          ●                 │
     │     E─────┴─────T          │   */
.tree-wrap {
  position: relative;
  width: fit-content;
  min-width: min(100%, 22rem);   /* a tree of nothing (every set off) is no wider than its legend: room for both corners clear of it */
  max-width: 100%;
  margin: 1.75rem auto 0;
}
.tree-wrap > .tree { margin: 0 auto; }
.tree-tools {
  position: sticky;
  top: 0.4rem;
  z-index: 2;
  height: 0;
}
.tree-tools button {
  position: absolute;
  top: 0;
  display: flex;
  padding: 0.2rem;
  border: 0;
  border-radius: 50%;
  background: var(--bakelite);
  color: var(--graphite);
  line-height: 0;
}
.tree-tools button::after { content: ""; position: absolute; inset: -0.4rem; }   /* roomy to tap */
.tree-tools .tree-replay { left: 0; }
.tree-tools .tree-expand { right: 0; }
.tree-tools svg { width: 0.9rem; height: 0.9rem; }
.tree-tools button:disabled { color: var(--wire); cursor: default; }
.tree-expand .in, .tree-expand[aria-pressed="true"] .out { display: none; }
.tree-expand[aria-pressed="true"] .in { display: inline; }
@media (hover: hover) {
  .tree-tools button:not(:disabled):hover { background: var(--bakelite); color: var(--brass); }
}
.tree-tools button:focus-visible { outline: 1px dashed var(--brass); outline-offset: 2px; }

/* expanded: the whole tree in a popup filling the screen, framed as
   /ref's other notes are (.ref-pop), scaled to fit (main.js sets the
   size), never a scroll; Escape, a tap outside or ⤢ again puts it back */
.tree-frame.expanded .tree-wrap {
  position: fixed;
  inset: 0;
  z-index: 50;
  width: auto;
  max-width: none;
  margin: 1rem;
  padding: 2.4rem 1rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--graphite);
  background: var(--bakelite);
  /* the backdrop: the page hidden, not dimmed (the trace keys the
     switch and fills the card under it: a page changing behind a
     popup is a distraction, or a worry) */
  box-shadow: 0 0 0 100vmax var(--bakelite);
}
.tree-frame.expanded .tree-wrap::before {   /* its label on the edge, as .frame-label */
  content: "tree";
  position: absolute;
  top: -0.75em;
  left: 0.8rem;
  padding: 0 0.6ch;
  background: var(--bakelite);
  color: var(--graphite);
  font-size: 15px;
  line-height: 1.5;
}
.tree-frame.expanded .tree-tools { position: absolute; top: 0.6rem; left: 0.6rem; right: 0.6rem; }
.tree-frame.expanded .tree { overflow: hidden; max-width: 100%; max-height: 100%; }
body.tree-expanded { overflow: hidden; }


/* ============================================================
 * SELECTED CHARACTER (its card: overview.js renderCard)
 * ============================================================ */

/*
 * The station's about column down the left, and across from each
 * part what goes with it (a row each, so they line up):
 *
 *   tree     its place: path, depth, parent, twin …
 *   marks    the card (type, code, glyph, weight, dots and dashes)
 *   name     how it sounds, and its timeline
 *   cut      the digit's timeline, what's not sent grey
 *   ~        how it could be misheard, one reading at a time
 */
.card {
  container-type: inline-size;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.25;
  color: var(--paper);
}

/*
 * The tile at the top left and the whole tree under it; the note at
 * the top right, the rows under it (overview.js renderCard). Narrow
 * (a phone's popup), the rows take the width and the tree goes
 * under them:
 *
 *   ┌char─┐  the 3rd most …          ┌char─┐  the 3rd most
 *   │  A  │   E   path  ● → E → A    │  A  │  common letter
 *   └─────┘  [A]  depth 2            └─────┘
 *     .H     ▬    ███ ███             E   path  ● → E → A
 *   .I       ALFA .- / di-dah / …    [A]  depth 2
 *   ●-A      cut  …                   …
 *     …      ~    …                   the whole tree
 */
.card-body {
  display: grid;
  grid-template-areas: "side note" "rows rows" "full full";
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 1rem;
  align-items: start;
}
.card-side { grid-area: side; margin-bottom: 1rem; }
.card-body > .card-note { grid-area: note; margin-bottom: 1rem; }
.card-rows {
  grid-area: rows;
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  column-gap: 1rem;
  align-items: start;
}
.card-full { grid-area: full; margin: 0.5rem 0 1rem; font-size: 13px; }
.card .card-full a { color: inherit; }   /* lit or dim, as the tree says */
@container (min-width: 30rem) {
  .card-body {
    grid-template-areas: "side note" "side rows" "full rows";
    grid-template-rows: auto auto 1fr;
  }
  .card-full { margin: 1.25rem 0 0; justify-self: center; }
}

.card a { color: var(--paper); text-decoration: none; }
.card .na, .card a.na, .card .na * { color: var(--graphite); }
.signal .card .dot  { color: var(--dot); }
.signal .card .dash { color: var(--dash); }

.card-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-bottom: 1.15rem;
}
.card-right { padding-bottom: 1.15rem; container-type: inline-size; }
/* a part's word (cut, ~) on its own row, so the right lines up with its letters */
.card-left.r-label, .card-right.r-label { padding-bottom: 0.15rem; }
.card-left.r-marks { padding-top: 0.2rem; }   /* level with the timeline's marks */

/* the little tree: parent, the edge down, it, its two children */
.card-tree { font-size: 1.1rem; line-height: 1.2; white-space: pre; }
.card-tree .tree-line { display: block; }
.card-tree { cursor: pointer; }   /* a tap walks it again (overview.js) */
.card .here { background: var(--paper); color: var(--bakelite); padding: 0 0.15em; }

/* its place in the whole tree */
.card-place {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  column-gap: 2ch;
}
.card-place dt { color: var(--graphite); }
.card-place dt.na { color: var(--wire); }   /* nothing there: dimmer still */
.card-place dd { white-space: nowrap; }
.card-place dd:has(.step) { white-space: normal; }
.card-place .step { white-space: pre; }

/* the marks, one per row, as the column draws them */
.card-marks { display: flex; flex-direction: column; align-items: center; gap: 0.3em; font-size: 1.5rem; }
.card-marks i { display: block; height: 0.42em; width: 0.42em; background: var(--paper); }
.card-marks i.dash { width: 1.3em; }
.signal .card-marks i.dot  { background: var(--dot); }
.signal .card-marks i.dash { background: var(--dash); }
/* tapped, they sound (js/shared/play-marks.js): each mark paper while it's on, over hover's brass */
.card-marks i.sounding, .about-marks i.sounding { background: var(--paper) !important; }

/* the card, like a periodic table's: type and code at the top, the
   glyph, its weight in units and its dots and dashes at the foot */
.card-tile-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.8rem 1rem; }
/* sized in its own em, so a smaller one (the cards on /ref) is the same, smaller */
.card-tile {
  flex: none;
  display: grid;
  grid-template: "type code" 2.6em "glyph glyph" 1fr "weight stats" 2.6em / max-content 1fr;   /* the same rows on every tile, so the glyphs line up */
  column-gap: 0.5em;
  width: 11.3em;
  height: 14.7em;
  padding: 0.45em 0.6em;
  border: 1px solid var(--wire);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.25;
  color: var(--graphite);
}
/* its letter just played through (overview.js): the border lit paper, fading back */
.card-tile.landed { animation: tile-landed 0.7s ease-out; }
@keyframes tile-landed { from { border-color: var(--paper); } }
.tile-type { grid-area: type; display: flex; flex-direction: column; }
.tile-type .also::before { content: "+ "; }
.card-tile .tile-code { grid-area: code; justify-self: end; white-space: nowrap; }
.signal .card-tile .tile-code .dot  { color: var(--dot); }
.signal .card-tile .tile-code .dash { color: var(--dash); }
.signal .card-tile .tile-stats .dot  { color: var(--dot); }
.signal .card-tile .tile-stats .dash { color: var(--dash); }
.tile-glyph { grid-area: glyph; display: grid; place-items: center; min-height: 0; }
.tile-glyph .stroked { width: 7.5em; height: 7.5em; }
.tile-glyph .char { color: var(--paper); font-size: 4.5em; line-height: 1; font-weight: 700; }
.tile-glyph .char.pro { font-size: 2em; }
.tile-glyph .char.na { color: var(--graphite); }
.tile-glyph:has(.stroked) .char { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.tile-weight { grid-area: weight; align-self: end; }
.tile-stats { grid-area: stats; justify-self: end; align-self: end; white-space: pre; text-align: right; }

/* beside the card (or under it, without the room): a prosign, another
   reading, a tidbit */
.card-note { flex: 1 1 9rem; min-width: 0; font-size: 0.9rem; line-height: 1.4; color: var(--graphite); }
.card-note b { color: var(--paper); font-weight: 400; }   /* the key words, lit; the rest grey */
.card-note:empty { display: none; }
.card-note p + p { margin-top: 0.5rem; }

/* a word (a Q code, an abbreviation; overview.js renderWord): its
   letters' tiles in a row, one thin frame round them all. The tiles
   shrink with a narrow page, so three always stand side by side */
.card.word { display: block; }
.word-tiles { display: inline-flex; gap: 0.5rem; padding: 0.5rem; border: 1px solid var(--wire); }
.word-tiles a { display: block; }
.word-tiles a:hover { background: transparent; }
.word-tiles .card-tile { font-size: clamp(0.4rem, 2vw, 0.75rem); }
.word-means { margin: 0.9rem 0 1rem; color: var(--graphite); }
.word-means b { color: var(--paper); margin-right: 0.5em; }
.word-sound { container-type: inline-size; }
@media (hover: hover) {
  .word-tiles a:hover .card-tile { border-color: var(--brass); }
}

/* the name as a stair, as in the column (js/core/stair.js) */
.card-name { color: var(--graphite); font-size: 1.3rem; }
.card .stair { display: block; position: relative; width: 100%; height: calc(var(--h) * 1em); }
.card .stair > * {
  position: absolute;
  left: calc(50% + var(--dx) * 0.72em);
  top: calc(var(--y) * 1em);
  transform: translateX(-50%);
  line-height: 1;
}
.card .stair .stress { color: var(--paper); font-weight: 700; }
/* the syllable being said (shared/voice.js say, core/stair.js lightSyllable) */
.card .stair .said,
.about-name.stair .said { color: var(--brass); }
.card-sign { color: var(--graphite); font-size: 1.1rem; white-space: nowrap; }

/* the ways its marks are written (overview.js writtenAs): the marks
   small over how they're said, small over them in words, then the
   blocks, a tap on any copies it */
.card-forms { display: flex; flex-direction: column; align-items: flex-start; padding-top: 0.15rem; }
.card .card-forms p { margin: 0; line-height: 1.2; }   /* (a popup's p + p gap is for prose) */
.card .card-forms .form-small { font-size: 0.85rem; }
.card .card-forms .form-words { font-weight: 700; margin-bottom: 0.55rem; }
.card .card-forms .form-block { line-height: 1; letter-spacing: 0; }
.card .card-forms .form-block.small { margin-top: 0.1rem; }
.card-sounds { font-weight: 700; margin-bottom: 0.3rem; }
.card-label { color: var(--graphite); font-size: 0.95rem; }
.card-stack { display: flex; flex-direction: column; align-items: center; }
.card .card-big { font-size: 1.3rem; font-weight: 700; line-height: 1.15; }
.card-right > p.na { font-size: 0.85rem; }

/*
 * A timeline: the marks along a wire, as long as they sound, filling
 * in once as they play (--t: when, --d: how long); under each
 * stretch a line and its letter. A unit is as wide as fits (--n: the
 * units in it), up to 0.7rem.
 */
.tl {
  --u: min(0.7rem, calc((100cqw - 2.5rem) / var(--n)));
  display: inline-flex;
  flex-direction: column;
}
.tl-marks {
  display: flex;
  align-items: center;
  background: linear-gradient(var(--wire), var(--wire)) center / 100% 1px no-repeat;
}
.tl-marks i { display: block; flex: none; }
.tl .m { position: relative; height: 0.9rem; background: var(--wire); }
.tl .m::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--paper);
  transform-origin: left;
  animation: tl-fill var(--d) linear var(--t) both;
}
.signal .tl .m.dot::after  { background: var(--dot); }
.signal .tl .m.dash::after { background: var(--dash); }
.tl .m.gone::after { content: none; }
@keyframes tl-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) { .tl .m::after { animation: none; } }

.tl-labels { display: flex; margin-top: 0.3rem; }
.tl-labels > * { flex: none; }
.tl-label { border-top: 1px solid var(--graphite); padding-top: 0.15rem; text-align: center; font-weight: 700; }

/* the misheard readings, one at a time: ˄ 1/8 ˅ */
/* the turn between the columns: it stays put, however long the reading,
   and the timeline starts where the others do. Centred in the room
   between the letters (one wide, 1.3rem, centred in the 4.5rem
   column) and the timeline (past the 1rem gap):

     │   M   ˄   ███ ███ │
     │   O  1/8          │
     │       ˅           │
         ├───┼───┤  equal  */
.card-heard { position: relative; }
.card-turn {
  position: absolute;
  left: calc((1rem + 4.5rem / 2 - 1.3rem * 0.3) / -2);
  top: -0.2rem;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
  color: var(--graphite);
  line-height: 1;
}
.card-turn span { display: block; min-width: 4ch; text-align: center; }
/* the chevrons drawn, not typed: ˄ and ˅ sit high in their line, so
   the count between them sat low */
.card-turn button {
  display: block;
  border: 0;
  padding: 0.1rem 0.3rem;
  background: transparent;
  color: var(--paper);
  line-height: 0;
}
.card-turn svg { display: block; width: 0.7rem; height: 0.4rem; }
/* one reading: nowhere to turn, greyed */
.card-turn button:disabled { color: var(--wire); cursor: default; }

/* the parts that do something, tapped: plain, as they were, brass to the pointer */
.card .card-tap { cursor: pointer; }
.card button.card-tap {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.card button.card-name { color: var(--graphite); font-size: 1.3rem; width: 100%; }
.card button.card-label { color: var(--graphite); font-size: 0.95rem; }
.card button.card-big { font-size: 1.3rem; font-weight: 700; line-height: 1.15; }
.card button.card-symbol { color: var(--paper); font-size: 2rem; font-weight: 700; line-height: 1; }   /* a symbol: itself; its word on a tap */
.card-sounds button.card-tap, .form-words button.card-tap { font-weight: 700; }
.card .tl { cursor: pointer; }
@media (hover: hover) {
  .card a:hover { background: transparent; }   /* not the page's paper block: brass, in place */
  .card a:hover, .card a:hover * { color: var(--brass); }
  .card .card-turn button:not(:disabled):hover { background: transparent; color: var(--brass); }
  .card button.card-tap:hover, .card button.card-tap:hover * { background: transparent; color: var(--brass); }
  .card .card-marks.card-tap:hover i { background: var(--brass); }
  .card .card-tile.card-tap:hover { border-color: var(--brass); }
}
.card a:focus-visible, .card-turn button:focus-visible, .card button.card-tap:focus-visible { outline: 1px dashed var(--brass); outline-offset: 2px; }


/* ============================================================
 * ALL CHARACTERS
 * ============================================================ */

.morse-code {
  max-width: 880px;   /* the page's width: the lists use it; each other group keeps its own (below) */
  margin: 0 auto;
}

/*
 * The chart's bar, on top of the letters, numbers and symbols, and
 * kept on screen while they go by (sticky inside .chart-chars, so it
 * lets go at the prosigns): cards, then with stroke on the player.
 * On a phone the player takes a line of its own.
 *
 *   [x] cards   ▷ 2.8s ━━━━━━┃━━━━━━━ ⟲3 │ speed 5 wpm  consecutive
 */
.chart-bar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 2ch;
  padding: 0.5rem 0;
  margin-bottom: 0.4rem;
  background: var(--bakelite);
}

/* cards: its box, then its word (what they are: a popup) */
.cards-switch {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 1ch;
  font-size: 0.9rem;
}
.flag-word {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--graphite);
  text-decoration: underline dotted;
  text-underline-offset: 0.25em;
}
:where(body:not(.tx)) .flag-word:hover { background: transparent; color: var(--brass); }

/* the chart's order (A–Z, most used first …), under the bar */
.chart-options { justify-content: center; margin-bottom: 0.6rem; }

/*
 * The stroke player (stroke on, js/ref/main.js), as the station's player
 * (station.css, "The player"): play, the scrub bar with the signal
 * drawn under a brass playhead, repeat with its 3 / ∞; the sheet's
 * settings on a row under it, words that are grey off, paper on.
 */
.stroke-player {
  flex: 1 1 22rem;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem 1.5ch;
  font-size: 0.85rem;
}
/* stroke off: its room kept, so switching stroke on moves nothing (the
   stroke box under the pointer least of all) */
.stroke-player[hidden] { display: flex; visibility: hidden; }
.stroke-play { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.6ch; }
/* the readout: one width, so the scrub bar never changes length */
.stroke-player .time { flex: none; width: 5ch; font-size: 0.75rem; color: var(--graphite); font-variant-numeric: tabular-nums; }
.stroke-player button {
  flex: none;
  border: 0;
  padding: 0.15rem 0.25rem;
  background: transparent;
  color: var(--graphite);
  line-height: 0;
}
.stroke-player .ico { width: 1.2rem; height: 1.2rem; }
.stroke-player .play { color: var(--paper); }
.stroke-player .play .i-pause, .stroke-player .play.on .i-play { display: none; }
.stroke-player .play.on .i-pause { display: inline; }
.stroke-player .repeat { position: relative; color: var(--wire); }
.stroke-player .repeat[aria-pressed="true"] { color: var(--paper); }
.stroke-player .repeat::after { position: absolute; right: 0; top: -0.3em; font-size: 0.7rem; font-weight: 700; line-height: 1; color: var(--brass); }
.stroke-player .repeat[data-repeat="three"]::after { content: "3"; }
.stroke-player .repeat[data-repeat="on"]::after { content: "∞"; }
.stroke-player .seek-wrap { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; }
.stroke-player .trace { position: absolute; left: 0; right: 0; top: 50%; width: 100%; height: 14px; transform: translateY(-50%); pointer-events: none; }
.stroke-player .seek {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 1.4rem;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  touch-action: none;
}
.stroke-player .seek::-webkit-slider-runnable-track { height: 1px; background: transparent; }
.stroke-player .seek::-moz-range-track { height: 1px; background: transparent; }
.stroke-player .seek::-webkit-slider-thumb { -webkit-appearance: none; width: 4px; height: 18px; margin-top: -8.5px; border: 0; border-radius: 2px; background: var(--brass); }
.stroke-player .seek::-moz-range-thumb { width: 4px; height: 18px; border: 0; border-radius: 2px; background: var(--brass); }
.stroke-player .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; }
.stroke-player .seek-pop canvas { display: block; width: 100%; height: 100%; }
/* past a rule, as the mock-up has it:  ⟲ │ speed 5 wpm  consecutive */
.stroke-settings { flex: none; display: flex; align-items: baseline; gap: 0.4rem 1.5ch; padding-left: 1.5ch; border-left: 1px solid var(--wire); color: var(--graphite); }
.stroke-settings button { line-height: inherit; padding: 0; }
/* a phone: two lines, the settings beside cards, the player under
   them, all its width for the scrub bar

     [x] cards        speed 5 wpm  consecutive
     ▷ 2.8s ━━━━━━━━━━━━━┃━━━━━━━━━━━━━━━ ⟲3          */
@media (max-width: 600px) {
  .stroke-player, .stroke-player[hidden] { display: contents; }
  .stroke-play { order: 2; flex-basis: 100%; }
  .stroke-settings { order: 1; margin-left: auto; padding-left: 0; border-left: 0; }
}
.stroke-settings button[aria-pressed="true"] { color: var(--paper); }
@media (hover: hover) {
  :where(body:not(.tx)) .stroke-player button:hover { background: transparent; color: var(--brass); }
}
.stroke-player button:focus-visible { outline: 1px dashed var(--brass); outline-offset: 2px; }

/* each character as its tile (js/ref/main.js), where the lists were */
.tile-grid { display: none; }
.morse-code.cards .tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 6.8rem);
  justify-content: center;
  gap: 0.6rem;
  margin: 0.8rem 0 1.8rem;
  list-style: none;
}
/* (a group's page: the other groups' grids are empty, and take no room) */
.morse-code.cards .tile-grid:empty { display: none; }
.morse-code.cards :is(.morse-letters, .morse-numbers, .morse-symbols, .lists[data-list="prosigns"]) { display: none; }
.list-grid > .tile-grid { grid-column: 1 / -1; contain: inline-size; }
.tile-grid a { display: block; color: inherit; text-decoration: none; }
.tile-grid a:hover { background: transparent; }   /* not the page's paper block: it overran the border */
.tile-grid .card-tile { font-size: 0.6rem; }
@media (hover: hover) {
  .tile-grid a:hover .card-tile { border-color: var(--brass); }
}
/* pressed: the tile printed the other way round, paper and bakelite
   swapped (the swap read on the link, so neither refers to itself) */
.tile-grid a:active {
  --swap-paper: var(--bakelite);
  --swap-bakelite: var(--paper);
  --swap-graphite: var(--wire);
  --swap-wire: var(--graphite);
}
.tile-grid a:active .card-tile {
  --paper: var(--swap-paper);
  --bakelite: var(--swap-bakelite);
  --graphite: var(--swap-graphite);
  --wire: var(--swap-wire);
  background: var(--bakelite);
}
.tile-grid a:focus-visible { outline: 1px dashed var(--brass); outline-offset: 2px; }

/* a note over the page (/ref: what the cards show) */
.ref-pop {
  margin: auto;
  width: min(24rem, calc(100vw - 2rem));
  padding: 1.1rem 1rem 0.9rem;
  border: 1px solid var(--graphite);
  background: var(--bakelite);
  color: var(--paper);
  font-size: 0.9rem;
  line-height: 1.45;
  overflow: visible;
}
.ref-pop::backdrop { background: color-mix(in srgb, var(--bakelite) 60%, transparent); }
.ref-pop .frame-label { left: 0.8rem; }
.ref-pop .close { position: absolute; top: 0.1rem; right: 0.3rem; border: 0; padding: 0 0.3rem; color: var(--graphite); }
:where(body:not(.tx)) .ref-pop .close:hover { background: transparent; color: var(--brass); }
.ref-pop p + p, .ref-pop pre + p { margin-top: 0.6rem; }
.cards-sketch { margin: 0.6rem 0; font-family: var(--mono); font-size: 0.85rem; line-height: 1.2; color: var(--graphite); white-space: pre; overflow-x: auto; }
.cards-sketch b { color: var(--paper); }
.cards-sketch .g { color: var(--graphite); }
.signal .cards-sketch .dot { color: var(--dot); }
.signal .cards-sketch .dash { color: var(--dash); }

/* short codes stay close to their characters; prosigns have long names */
:is(.morse-code, .chart-chars) > h2,
:is(.morse-code, .chart-chars) > .heading-row,
.morse-code .group-row {
  max-width: 400px;
  margin-inline: auto;
}


.morse-code h2 {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--paper);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.morse-code h2:first-child {
  margin-top: 0;
}

/* each group's heading is the way to its own page (/ref/alphabet/ …) */
.morse-code h2 a { color: inherit; text-decoration: none; }
@media (hover: hover) {
  .morse-code h2 a:hover { background: transparent; color: var(--brass); }
}
.morse-code h2 a:focus-visible { outline: 1px dashed var(--brass); outline-offset: 2px; }

/*
 * A group's own page (/ref/alphabet/, made from this one by
 * tools/ref-groups.cjs): the reference, its parts for that group
 * alone (data-group, on each), a word on it at the top, and its table
 * as text at the foot. The whole chart (/ref/chart/) is all of it but
 * the tree; the tree (/ref/tree/) is the tree, and the selected
 * character, alone.
 *
 *   ┌ tree ───────────┐      /ref/prosigns/:    ┌ selected ┐
 *   ┌ selected ───────┐      (no tree: they're  ┌ prosigns ┐
 *   ┌ alphabet ───────┐       words, or run     ┌ as text  ┐
 *   ┌ as text ────────┐       off its foot)
 */
.ref-lead { max-width: 62ch; margin: 0 0 1.5rem; color: var(--graphite); }
.ref-lead b { color: var(--paper); font-weight: 400; }
body[data-focus="chart"] .tree-frame,
body[data-focus="tree"] .chart-frame { display: none; }
body[data-focus="alphabet"] [data-group]:not([data-group~="alphabet"]),
body[data-focus="numbers"] [data-group]:not([data-group~="numbers"]),
body[data-focus="symbols"] [data-group]:not([data-group~="symbols"]),
body[data-focus="prosigns"] [data-group]:not([data-group~="prosigns"]),
body[data-focus="q-codes"] [data-group]:not([data-group~="q-codes"]),
body[data-focus="abbreviations"] [data-group]:not([data-group~="abbreviations"]) { display: none; }
/* the prosigns' page: cards too (its tiles have nothing to draw, so no
   stroke player), and as cards the grid takes the frame's width: with
   its lists hidden it has nothing else to be as wide as (it was one
   tile wide, a column) */
body[data-focus="prosigns"] .stroke-player { display: none; }
body[data-focus="prosigns"] .morse-code.cards .list-grid { width: 100%; }
/* a group's find box (js/ref/main.js): the entries it doesn't match go */
.find-frame input {
  width: 100%;
  padding: 0.3rem 0;
  border: 0;
  border-bottom: 1px solid var(--wire);
  background: transparent;
  color: var(--paper);
  font: inherit;
}
.find-frame input::placeholder { color: var(--wire); }
.find-frame input:focus-visible { outline: none; border-bottom-color: var(--brass); }
@media (hover: hover) { .find-frame input:hover { border-bottom-color: var(--brass); } }
.find-none { margin: 0.6rem 0 0; color: var(--graphite); }
.morse-code :is(li, .lists li).unfound { display: none; }
/* on a group's page the lead says what the group is, the frames' width */
body[data-focus] .ref-lead { max-width: none; }
/*
 * Phrases (js/ref/phrases.js): a row each, its words over its Morse,
 * play at the left, ⋯ at the right (the station, a .wav, a link).
 *
 *   ▷  I love you                                        ⋯
 *      .. / .-.. --- ...- . / -.-- --- ..-
 *      (a note, where it has one)
 */
.morse-code .phrases { max-width: 38rem; margin: 2.5rem auto 0; }
.morse-code .phrases h2 { margin-top: 0; }
.phrase-list { list-style: none; margin: 0.6rem 0 0; padding: 0; }
.morse-code .phrase a { display: inline; padding: 0; line-height: inherit; }   /* not the lists' rows (.morse-code li a) */
.phrase {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  column-gap: 1.2ch;
  row-gap: 0.15rem;
  align-items: center;
  padding: 0.55rem 0;
  border-top: 1px solid var(--wire);
}
.phrase:last-child { border-bottom: 1px solid var(--wire); }
.notes ul.phrase-list li.phrase { padding-left: 0; text-indent: 0; margin: 0; }   /* (a page to read: not its list's bullets) */
.notes ul.phrase-list li.phrase::before { content: none; }
.phrase > * { grid-column: 2; }
.phrase-play, .phrase-more { grid-row: 1; }
.phrase-play { grid-column: 1; }
.phrase-more { grid-column: 3; }
.phrase-play, .phrase-more {
  display: inline-flex;
  padding: 0.25rem;
  border: 0;
  background: transparent;
  color: var(--graphite);
  cursor: pointer;
}
.phrase-play .ico, .phrase-more .ico { width: 1.1rem; height: 1.1rem; }
.phrase.playing .phrase-play { color: var(--paper); }
@media (hover: hover) {
  .phrase-play:hover, .phrase-more:hover { color: var(--brass); background: transparent; }
}
.phrase-play:focus-visible, .phrase-more:focus-visible { outline: 1px dashed var(--brass); outline-offset: 1px; }
.phrase-more[aria-expanded="true"] { color: var(--paper); }
.phrase-text { grid-row: 1; justify-self: start; color: var(--paper); font-weight: 700; text-decoration: none; }
@media (hover: hover) { .phrase-text:hover { color: var(--brass); background: transparent; } }
.phrase-code { font-family: var(--mono); letter-spacing: 0.08em; overflow-wrap: anywhere; color: var(--graphite); }
.phrase-code i { font-style: normal; transition: color 0.05s linear; }
.signal .phrase-code .dot { color: var(--dot); }
.signal .phrase-code .dash { color: var(--dash); }
.phrase-code i.sounding { color: var(--paper); }
.phrase-note { color: var(--graphite); font-size: 0.85em; }
.phrase-menu {
  position: absolute;
  right: 0;
  top: calc(100% - 0.3rem);
  z-index: 4;
  display: flex;
  flex-direction: column;
  min-width: 12ch;
  padding: 0.3rem 0;
  background: var(--bakelite);
  border: 1px solid var(--graphite);
}
.phrase-menu[hidden] { display: none; }
.morse-code .phrase-menu :is(a, button),
.phrase-menu :is(a, button) {
  display: block;
  padding: 0.35rem 1.2ch;
  border: 0;
  background: transparent;
  color: var(--graphite);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
@media (hover: hover) { .phrase-menu :is(a, button):hover { color: var(--brass); background: transparent; } }
.phrase-said { margin: 0; padding: 0 1.2ch; color: var(--paper); font-size: 0.85em; }
.phrase-said:empty { display: none; }

/* a list's page has no chart above its order menu to keep apart from */
body:is([data-focus="prosigns"], [data-focus="q-codes"], [data-focus="abbreviations"]) .list-options { margin-top: 0; }

/* a heading with its group's switch at the right edge:
     Letters ···························· [ ] stroke        */
.morse-code .heading-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1ch;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}
.morse-code > .heading-row:first-child { margin-top: 0; }
.morse-code .heading-row h2 { margin: 0; }
.morse-code .heading-row .check { font-size: 0.85rem; color: var(--graphite); }   /* the heading is the one in white */
/* more than one switch: one over the other, their boxes in a column
     Letters ··················· stroke [x]
                                circles [ ]                           */
.morse-code .heading-row .switches { display: flex; flex-direction: column; align-items: flex-end; }

.morse-code ul {
  list-style: none;
  flex: 1;
}

.morse-code .group-row {
  display: flex;
  gap: 2.5rem;
}

.morse-code li a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1ch;
  padding: 0 0.5ch;
  text-decoration: none;
  line-height: 1.6;
}

/* codes are what you type (. and -), bold so a period still reads */
.morse-code .code {
  color: var(--paper);
  font-weight: 700;
  letter-spacing: 0.25em;
  white-space: nowrap;
}

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

.morse-code li a:hover .code,
.morse-code li a:hover .code span {
  color: inherit;
}

/* the phonetic name, greyed, beside its character (on the inner
   side, so the codes stay at the outer edges). Plain graphite and no
   dimmer: at this size it's as faint as small text can be and still
   be read (4.5 to 1 against the background, in either theme) */
.morse-code .say {
  color: var(--graphite);
  font-size: 0.78em;
  white-space: nowrap;
}

.morse-code .col-left .say  { margin-left: auto; }
.morse-code .col-right .say { margin-right: auto; }

/* wing effect: codes at the outer edge of each column */
.morse-code .col-left .code {
  text-align: right;
}

/* cut numbers (the chart's box): the marks a cut drops greyed, and
   the letter it's sent as outside its code; its room always kept */
.morse-code .cut-as { visibility: hidden; min-width: 1ch; color: var(--graphite); }   /* grey: white is the digit's own */
.morse-code.cut .cut-as { visibility: visible; }
.morse-code.cut .morse-numbers .code span.gone { color: var(--wire); }

/*
 * Stroke letters (js/core/strokes.js), when chosen: the drawing in the
 * label, the plain character still there but hidden. Sized to the
 * line, its foot on the baseline (the box has 14 of its 128 units
 * below the letter), so the rows keep their height.
 */
.morse-code .label .stroked { display: none; }
.morse-code.strokes .label .stroked {
  display: inline-block;
  height: 1.25em;
  width: 1.25em;
  margin-bottom: calc(-1.25em * 14 / 128);
}
/* a number in its full form, or with cut on its cut one (0: one dah) */
.morse-code.strokes:not(.cut) .label .stroked.cut-form,
.morse-code.strokes.cut .label .stroked.full-form { display: none; }
.morse-code.strokes .label:has(.stroked) > span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.stroked path { fill: none; }
.stroked .scaffold path { stroke: var(--graphite); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.stroked.keyed .scaffold path { stroke: var(--paper); }
.stroked .ink path { fill: none; stroke: var(--paper); stroke-width: 1px; vector-effect: non-scaling-stroke; }   /* the thin letter, inked as the pen goes */
.stroked .grey path { stroke: var(--wire); }
.stroked .fill .dot { stroke: var(--dot); }
.stroked .fill .dash { stroke: var(--dash); }
/* circles (the stroke player's setting): a disc, filled, never ringed */
.stroked .grey circle { fill: var(--wire); stroke: none; }
.stroked .fill circle.dot { fill: var(--dot); stroke: none; }
body:not(.signal) :is(.morse-code, .card) .stroked .fill path { stroke: var(--paper); }   /* dot/dash colours off (only /ref has the switch) */
body:not(.signal) :is(.morse-code, .card) .stroked .fill circle { fill: var(--paper); }

@media (hover: hover) {
  .morse-code li a:hover .stroked :is(.scaffold, .ink) path { stroke: var(--brass); }
}

/* the narrowest phones: tighter, so both wings and their names fit */
@media (max-width: 360px) {
  .morse-code .group-row { gap: 0.75rem !important; }
  .morse-code li a { gap: 0.6ch; padding: 0; }
  .morse-code .say { font-size: 0.68em; letter-spacing: -0.02em; }
}

/*
 * Phones keep the two wings side by side, characters meeting
 * in the middle, codes on the outside:
 *
 *   .-      A  N      -.
 *   -...    B  O     ---
 */
@media (max-width: 480px) {
  .morse-code .group-row {
    gap: 1.25rem;
  }

  .morse-code .code {
    letter-spacing: 0.15em;
  }

}


/* ============================================================
 * SMALL SCREENS
 * ============================================================ */

@media (max-width: 600px) {
  body {
    padding: calc(1.25rem + var(--safe-top)) calc(1rem + var(--safe-x)) calc(3rem + var(--safe-bottom));
  }

  .frame {
    --frame-top: 1.5rem;
    --frame-side: 1rem;
    padding-bottom: 1.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tree span {
    transition: none;
  }
}

/* opened at the tree (#cut): a little room above its label */
.tree-frame { scroll-margin-top: 0.75rem; }

/*
 * The switch on the tree frame's bottom edge (the station's, sized
 * and placed the same): open, the lever lifts off the line; closed,
 * it drops into it, the LED lit, and the frame glows brass, as the
 * station's box does while a key is down. A link to the station.
 */
.tree-frame .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);
  text-decoration: none;
}
.tree-frame .switch svg {
  position: relative;
  width: 30px;
  height: 32.5px;
}
.tree-frame .switch::before {        /* the line under the lever, cleared */
  content: "";
  position: absolute;
  left: 1px;
  width: 28px;
  top: calc(21.7px - 2.5px);
  height: 4px;
  background: var(--bakelite);
}
.tree-frame .switch:hover {          /* not the page's filled link hover: just the brass lever */
  background: transparent;
}
.tree-frame .switch::after {         /* a little more to aim at */
  content: "";
  position: absolute;
  inset: -6px -8px;
}
.tree-frame.lit {                    /* the station's lamp, exactly (station.css .station.lit) */
  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);
}

/* its label lights with it: the gap it leaves in the edge reads as
   part of the lit frame, not a hole in the glow */
.tree-frame > .frame-label {         /* only the edge's own line hidden behind the word,
                                        not a box (which would cut a hole in the glow) */
  background: linear-gradient(transparent calc(50% - 2px), var(--bakelite) calc(50% - 2px) calc(50% + 2px), transparent calc(50% + 2px));
}
.tree-frame.lit > .frame-label {
  color: var(--brass);
  text-shadow: 0 0 8px color-mix(in srgb, var(--brass) 60%, transparent);
}

/* a signal drawn as shapes, not block characters (fonts draw those
   at different heights and widths): one character wide per unit */
.bar .on { background: var(--paper); }

/*
 * Prosigns, Q codes, abbreviations: one to a line, in one grid the
 * three lists share (each list and row a subgrid of it): the code at
 * the left, the term on the centre line, the meaning at the right
 * (wrapping there). Equal outer columns keep the terms on one axis,
 * and the grid is only as wide as they need: the longest code and
 * the longest meaning (QSY?, RST), not the page. A whole row is one
 * link (it lights as one).
 *
 *        ...---...       SOS       distress
 *        -...-.-          BK       break: back to you
 *
 * The headings and notes span it, but don't widen it (they take the
 * grid's width, not their own: contain: inline-size).
 */
.morse-code .list-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content minmax(0, 1fr);
  column-gap: 2ch;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
}
.morse-code .list-grid > * { grid-column: 1 / -1; }
.morse-code .list-grid > :not(.lists) { contain: inline-size; margin-inline: 0; }   /* stretched across, not shrunk to nothing */
.morse-code .list-grid > h2 { max-width: 100%; }   /* at the left, as the Q codes' row and the groups above */
.morse-code .cheat-note {
  margin: 0 0 0.6rem;
  color: var(--graphite);
  font-size: 0.85rem;
  text-align: center;
}
.morse-code .list-options {
  justify-content: center;
  margin: 2rem 0 0;
}

.morse-code .lists {
  display: grid;
  grid-template-columns: subgrid;
  margin: 0;
  padding: 0;
  list-style: none;
}
.morse-code .lists li { display: contents; }
.morse-code .lists li a {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  align-items: baseline;
  padding-block: 0.075rem;
}
.morse-code .lists .code { text-align: left; letter-spacing: 0.12em; }   /* whole words: closer than the letters' */
.morse-code .lists .label { font-weight: 700; letter-spacing: 0.08em; white-space: nowrap; text-align: center; }
.morse-code .lists .means {
  color: var(--graphite);
  font-size: 0.78em;
  line-height: 1.3;
  text-align: right;
}
.morse-code .lists li a:hover .means { color: inherit; }

/*
 * Prosigns as bar notation (the "bar" box): the letters with a bar
 * over them, the old way, instead of brackets. The brackets keep
 * their room, unseen, so the centre column holds its width.
 *
 *    <AR>   →    ‾‾
 *                AR
 */
.morse-code.bar .label.pro .br { visibility: hidden; }
.morse-code.bar .label.pro .pro-letters { text-decoration: overline; text-decoration-thickness: 0.08em; }
/* the cards too: the brackets gone (a tile has room to centre the letters) */
.morse-code.bar .tile-glyph .br { display: none; }
.morse-code.bar .tile-glyph .pro-letters { text-decoration: overline; text-decoration-thickness: 0.08em; }

/* an answer's "?" slot (js/ref/main.js): its room kept, so QRL and QRL?
   centre the same and the letters don't move */
.morse-code .lists .label .q.unseen { visibility: hidden; }

/*
 * A Q code, answer or question ("?"): the other row stays in the grid
 * at no height, unseen, so the widths (and the centre line) hold
 */
.morse-code[data-q="answer"] .lists li[data-ask] a,
.morse-code[data-q="ask"] .lists[data-list="q-codes"] li:not([data-ask]) a {
  visibility: hidden;
  height: 0;
  padding-block: 0;
  overflow: hidden;
}

/* phones: the outer columns are narrow, so a long code (a Q code with
   its ?) breaks between its letters, never inside one
       --.- .-. .-..      QRL?    is this
       ..--..                     frequency in use?            */
@media (max-width: 480px) {
  .morse-code .lists .code { white-space: normal; }
}


/*
 * ============================================================
 * SHORT SCREENS: popups that scroll
 * ============================================================
 *
 * A phone on its side is 360 to 410px tall: the share menu, the
 * profile, some popups and Key hero's results run past the bottom.
 * They scroll, then. But a scrolling box clips whatever pokes out of
 * it, and the label sits on the frame's top line, half above it. So
 * the box reaches up by --lift over its frame, and draws the frame
 * itself (backgrounds, fixed to the box as it scrolls) that far down:
 *
 *      ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐  the box's top: a strip dimmed as
 *       ┌─ share ─────────┐      the page behind it        ▲ --lift
 *       │  copy morse      │   the frame, drawn            ▼
 *       │  …               │   the label and the close scroll
 *       └──────────────────┘   away with what's under them
 *
 * Unscrolled, it's where and as it was, line for line.
 */
@media (max-height: 560px) {
  :root :is(.popup, .share-menu),     /* :root: over station.css's own */
  .hero .result {
    --lift: 0.75rem;
    --dim: color-mix(in srgb, var(--bakelite) 60%, transparent);
    --line: linear-gradient(var(--graphite), var(--graphite));
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--wire) transparent;
    border-color: transparent;
    background:
      var(--line) 0 var(--lift) / 100% 1px,
      var(--line) 0 var(--lift) / 1px 100%,
      var(--line) 100% var(--lift) / 1px 100%,
      var(--line) 0 100% / 100% 1px,
      linear-gradient(var(--dim), var(--dim)) 0 0 / 100% var(--lift),
      linear-gradient(var(--bakelite), var(--bakelite)) 0 var(--lift) / 100% 100%;
    background-repeat: no-repeat;
    background-origin: border-box;
  }

  :is(.popup, .share-menu, .hero .result) > .frame-label {
    top: calc(var(--lift) - 0.75em);
  }

  :is(.popup, .share-menu, .hero .result) > .close {
    margin-top: var(--lift);
  }

  /* centred: grows by --lift, so half of it up */
  :root .popup {
    padding-top: calc(1.1rem + var(--lift));
    margin-top: calc(var(--lift) / -2);
    max-height: calc(100dvh - 0.75rem);
  }

  /* under the share button */
  :root .share-menu {
    --dim: color-mix(in srgb, var(--bakelite) 55%, transparent);
    padding-top: calc(1rem + var(--lift));
    margin-top: calc(-1 * var(--lift));
    max-height: calc(100dvh - var(--share-top, 3rem) + var(--lift) - 0.5rem);
  }

  /* the results: over the screen rather than a share of the stage */
  .hero .result {
    position: fixed;
    inset: 0.5rem 0 auto;
    padding-top: calc(1rem + var(--lift));
    max-height: calc(100dvh - 1rem);
  }
}
