/* keymorse: a black-soldermask board with gold traces, silkscreen
   lettering, green dot lamps and red dash lamps. */
:root {
  --mask: #0c0e0d;
  --board: #121514;
  --gold: #d6ab52;
  --gold-mid: #8a6f35;
  --gold-hot: #f6d27a;
  --silk: #f0ede3;
  --silk-dim: #908e86;
  --green: #4af08c;
  --red: #ff4d40;
  --lens-green: #12301f;
  --lens-red: #3a1513;
  --ui: 'Jura', 'Segoe UI', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  --fs: 1.5rem;
  --lh: 2.2rem;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--mask);
  color: var(--silk);
  font-family: var(--ui);
  font-weight: 500;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  touch-action: manipulation;
}

/* On a wide screen paper tapes cross each side of the page: KEYMORSE in
   dots and dashes, over and over. It is faint and it never moves, and it
   thins out towards the edge of the window. The board is the thing to watch. */
@media (min-width: 1100px) {
  body::before, body::after {
    content: '';
    position: fixed;
    top: 0;
    bottom: 0;
    width: calc(50% - 430px - 56px);
    background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='492' height='240'><rect x='0' y='0' width='18' height='6' rx='3' fill='%23d6ab52'/><rect x='24' y='0' width='6' height='6' rx='3' fill='%23d6ab52'/><rect x='36' y='0' width='18' height='6' rx='3' fill='%23d6ab52'/><rect x='72' y='0' width='6' height='6' rx='3' fill='%23d6ab52'/><rect x='96' y='0' width='18' height='6' rx='3' fill='%23d6ab52'/><rect x='120' y='0' width='6' height='6' rx='3' fill='%23d6ab52'/><rect x='132' y='0' width='18' height='6' rx='3' fill='%23d6ab52'/><rect x='156' y='0' width='18' height='6' rx='3' fill='%23d6ab52'/><rect x='192' y='0' width='18' height='6' rx='3' fill='%23d6ab52'/><rect x='216' y='0' width='18' height='6' rx='3' fill='%23d6ab52'/><rect x='252' y='0' width='18' height='6' rx='3' fill='%23d6ab52'/><rect x='276' y='0' width='18' height='6' rx='3' fill='%23d6ab52'/><rect x='300' y='0' width='18' height='6' rx='3' fill='%23d6ab52'/><rect x='336' y='0' width='6' height='6' rx='3' fill='%23d6ab52'/><rect x='348' y='0' width='18' height='6' rx='3' fill='%23d6ab52'/><rect x='372' y='0' width='6' height='6' rx='3' fill='%23d6ab52'/><rect x='396' y='0' width='6' height='6' rx='3' fill='%23d6ab52'/><rect x='408' y='0' width='6' height='6' rx='3' fill='%23d6ab52'/><rect x='420' y='0' width='6' height='6' rx='3' fill='%23d6ab52'/><rect x='444' y='0' width='6' height='6' rx='3' fill='%23d6ab52'/><rect x='246' y='120' width='18' height='6' rx='3' fill='%23d6ab52'/><rect x='270' y='120' width='6' height='6' rx='3' fill='%23d6ab52'/><rect x='282' y='120' width='18' height='6' rx='3' fill='%23d6ab52'/><rect x='318' y='120' width='6' height='6' rx='3' fill='%23d6ab52'/><rect x='342' y='120' width='18' height='6' rx='3' fill='%23d6ab52'/><rect x='366' y='120' width='6' height='6' rx='3' fill='%23d6ab52'/><rect x='378' y='120' width='18' height='6' rx='3' fill='%23d6ab52'/><rect x='402' y='120' width='18' height='6' rx='3' fill='%23d6ab52'/><rect x='438' y='120' width='18' height='6' rx='3' fill='%23d6ab52'/><rect x='462' y='120' width='18' height='6' rx='3' fill='%23d6ab52'/><rect x='6' y='120' width='18' height='6' rx='3' fill='%23d6ab52'/><rect x='30' y='120' width='18' height='6' rx='3' fill='%23d6ab52'/><rect x='54' y='120' width='18' height='6' rx='3' fill='%23d6ab52'/><rect x='90' y='120' width='6' height='6' rx='3' fill='%23d6ab52'/><rect x='102' y='120' width='18' height='6' rx='3' fill='%23d6ab52'/><rect x='126' y='120' width='6' height='6' rx='3' fill='%23d6ab52'/><rect x='150' y='120' width='6' height='6' rx='3' fill='%23d6ab52'/><rect x='162' y='120' width='6' height='6' rx='3' fill='%23d6ab52'/><rect x='174' y='120' width='6' height='6' rx='3' fill='%23d6ab52'/><rect x='198' y='120' width='6' height='6' rx='3' fill='%23d6ab52'/></svg>");
    opacity: 0.13;
    pointer-events: none;
  }
  body::before { left: 0; background-position: right 0 top 0; -webkit-mask-image: linear-gradient(to left, #000, transparent 440px); mask-image: linear-gradient(to left, #000, transparent 440px); }
  body::after { right: 0; background-position: left 0 top 0; -webkit-mask-image: linear-gradient(to right, #000, transparent 440px); mask-image: linear-gradient(to right, #000, transparent 440px); }
}

button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--silk); outline-offset: 2px; }

.app {
  height: 100vh;
  height: 100dvh;
  max-width: 860px;
  margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* From the column's inner edge out to the window's edge, each side. */
  --edge-l: calc(max(0px, (100vw - 860px) / 2) + max(12px, env(safe-area-inset-left)));
  --edge-r: calc(max(0px, (100vw - 860px) / 2) + max(12px, env(safe-area-inset-right)));
}

/* ---------- top rows ---------- */
.top, .config { display: flex; align-items: center; justify-content: space-between; flex: none; }
.top { gap: 10px; }
.top .mark { flex: 1; min-width: 0; }
.modes { display: flex; flex: none; border: 1.5px solid var(--gold-mid); border-radius: 9px; overflow: hidden; }
.modes button {
  appearance: none;
  background: none;
  border: 0;
  height: 30px;
  padding: 0 12px;
  color: var(--silk-dim);
  font-weight: 700;
  cursor: pointer;
}
.modes button[aria-pressed="true"] { background: var(--gold); color: var(--mask); }
.app[data-mode="course"] .set-lab, .app:not([data-mode="course"]) .course-bar { display: none; }
.course-bar { display: flex; align-items: center; gap: 12px; }
.focus-lab { color: var(--silk-dim); font-size: 0.9rem; }
.focus-lab b { color: var(--gold-hot); font-size: 1.1rem; margin-left: 2px; }

.mark {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 5px;
}
.mark a { display: flex; align-items: center; gap: inherit; color: inherit; text-decoration: none; border-radius: 6px; }
.mark-dot, .mark-dash { display: block; height: 9px; border-radius: 5px; }
.mark-dot { width: 9px; background: var(--green); }
.mark-dash { width: 22px; background: var(--red); margin-right: 5px; }
.mark-text { white-space: nowrap; }

.icon-btn {
  appearance: none;
  background: none;
  border: 0;
  width: 40px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--gold);
  border-radius: 8px;
  cursor: pointer;
}

.set-lab .chip:empty { display: none; }

.chip {
  appearance: none;
  background: none;
  border: 1.5px solid var(--gold-mid);
  color: var(--silk-dim);
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}
.chip { padding: 0 12px; color: var(--gold); }

/* ---------- the words ---------- */
.text {
  flex: none;
  height: calc(var(--lh) * 3);
  overflow: hidden;
  font-family: var(--mono);
  font-size: var(--fs);
  line-height: var(--lh);
}
.words {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  column-gap: 0.62em;
  transition: transform 0.15s ease-out;
}
.word { display: inline-flex; }
.ch { position: relative; color: var(--silk-dim); }
.ch.ok { color: var(--silk); }
.ch.fixed { color: #ff9a8f; }
.ch.cur { color: var(--gold-hot); }
.ch.cur::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.2em;
  height: 2px;
  background: var(--gold-hot);
}
.ch.shake { animation: shake 0.25s; }
@keyframes shake {
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* ---------- readout: what has been keyed for this letter ---------- */
.readout {
  position: relative;
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 10px;
}
.slots { flex: 1; display: flex; align-items: center; gap: 7px; height: 36px; }
.el { display: block; height: 14px; border: 2px solid var(--silk-dim); border-radius: 8px; flex: none; }
.el.dot { width: 14px; }
.el.dash { width: 36px; }
.el.on.dot { background: var(--green); border-color: var(--green); }
.el.on.dash { background: var(--red); border-color: var(--red); }
.say { order: 5; flex: 0 0 100%; margin: 0; min-height: 1.45em; font-size: 0.95rem; line-height: 1.45; color: #ff9a8f; }
.say.info { color: var(--silk-dim); }
/* On a narrow screen the line can wrap, so room for two lines is always kept:
   the diagram below never moves when a message shows. */
@media (max-width: 559px) { .say { height: 2.9em; overflow: hidden; } }
.say .el { display: inline-block; height: 9px; border: 0; margin: 0 1px; vertical-align: middle; }
.say .el.dot { width: 9px; background: var(--green); }
.say .el.dash { width: 20px; background: var(--red); }
.counter { color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }
.pause { position: absolute; left: 0; top: 34px; height: 2px; width: 0; background: var(--gold); }
.pause.run { animation: drain 600ms linear forwards; }
@keyframes drain { from { width: 100%; } to { width: 0; } }

/* ---------- the board ---------- */
.board {
  flex: 1 1 0;
  min-height: 0;
  background: var(--board);
  border: 1.5px solid var(--gold-mid);
  border-radius: 16px;
  padding: 6px;
  display: flex;
}
#tree { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-select: none; }
/* Settings can hide the diagram. The key grows into the room it leaves. */
.app[data-tree="hide"] .board { display: none; }
.app[data-tree="hide"] .keys { flex: 1 1 0; height: auto; min-height: 104px; max-height: 300px; }

.trace { stroke: var(--gold-mid); stroke-width: 5; stroke-linecap: round; }
.trace.guide { stroke: var(--gold-hot); }
.trace.lit, .trace.flash-ok { stroke: var(--silk); }
.trace.off { opacity: 0.3; }

.ant-pad { fill: var(--board); stroke: var(--gold); stroke-width: 4; }
.ant-mark { fill: none; stroke: var(--gold); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.app:not([data-tone=""]) .ant-pad { stroke: var(--silk); filter: drop-shadow(0 0 10px var(--gold-hot)); }
.app:not([data-tone=""]) .ant-mark { stroke: var(--silk); }

.node { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.node:focus { outline: none; }
.node:focus-visible .pad { stroke: var(--silk); stroke-width: 7; }
.node .hit { fill: transparent; }
.node .pad { fill: var(--lens-green); stroke: var(--gold); stroke-width: 4; }
.node.dash .pad { fill: var(--lens-red); }
.node text {
  fill: var(--silk);
  font-family: var(--ui);
  font-weight: 700;
  font-size: 34px;
  text-anchor: middle;
  pointer-events: none;
}
.node.off { opacity: 0.3; }
.node.guide .pad { stroke: var(--gold-hot); stroke-width: 5; }
.node.target .pad { stroke: var(--silk); stroke-width: 7; }

.node.lit .pad, .node.flash-ok .pad {
  fill: var(--green);
  stroke: #dcffe9;
  filter: drop-shadow(0 0 12px var(--green));
}
.node.dash.lit .pad, .node.dash.flash-ok .pad {
  fill: var(--red);
  stroke: #ffe1dd;
  filter: drop-shadow(0 0 12px var(--red));
}
.node.lit text, .node.flash-ok text { fill: #07130b; }
.node.dash.lit text, .node.dash.flash-ok text { fill: #1a0503; }
.node.learning .pad { stroke-dasharray: 9 6; }
.node.focus:not(.lit):not(.flash-ok):not(.target) .pad { stroke: var(--gold-hot); stroke-width: 6; animation: focus 1.8s ease-in-out infinite; }
@keyframes focus { 50% { stroke-width: 9; } }
.node.flash-bad { animation: bad 0.32s steps(1); }
@keyframes bad {
  0%, 50% { opacity: 1; }
  25%, 75% { opacity: 0.15; }
}

.legend text { fill: var(--silk-dim); font-family: var(--ui); font-weight: 500; font-size: 24px; dominant-baseline: central; }
.legend .l-dot { fill: var(--green); }
.legend .l-dash { fill: var(--red); }
.rx-hint .dot { fill: var(--green); }
.rx-hint .dash { fill: var(--red); }

/* ---------- paddles ---------- */
.keys { flex: none; height: 104px; display: flex; gap: 10px; }
.paddle {
  appearance: none;
  flex: 1 1 0;
  background: var(--board);
  border: 2px solid var(--gold);
  border-radius: 18px;
  color: var(--silk);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.paddle .glyph { display: block; height: 22px; border-radius: 12px; }
.paddle.dot .glyph { width: 22px; background: var(--green); }
.paddle.dash .glyph { width: 66px; background: var(--red); }
.paddle .cap { font-size: 0.95rem; letter-spacing: 0.04em; }

.app[data-keying="paddles"] .paddle.key { display: none; }
.app[data-keying="key"] .paddle.dot, .app[data-keying="key"] .paddle.dash { display: none; }

.app[data-tone="."] .paddle.dot { background: var(--lens-green); border-color: var(--green); box-shadow: 0 0 26px -6px var(--green); }
.app[data-tone="-"] .paddle.dash { background: var(--lens-red); border-color: var(--red); box-shadow: 0 0 26px -6px var(--red); }
.app[data-tone="k"] .paddle.key { background: #2a2312; border-color: var(--gold-hot); box-shadow: 0 0 26px -6px var(--gold-hot); }

.hints { display: none; }

/* ---------- results ---------- */
.results { flex: none; display: flex; flex-direction: column; gap: 12px; padding: 4px 0 6px; }
.score { display: flex; gap: 28px; align-items: flex-end; }
.score div { display: flex; flex-direction: column; }
.score b { font-size: 2.6rem; line-height: 1; color: var(--gold-hot); font-variant-numeric: tabular-nums; }
.score div + div b { font-size: 1.7rem; color: var(--silk); }
.score span { color: var(--silk-dim); font-size: 0.9rem; margin-top: 4px; }
.best { margin: 0; color: var(--silk-dim); font-size: 0.95rem; }
.weak { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 0.95rem; color: var(--silk-dim); }
.weak button {
  appearance: none;
  background: none;
  border: 1.5px solid var(--gold-mid);
  border-radius: 8px;
  height: 34px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--silk);
  font-weight: 700;
  cursor: pointer;
}
.weak button .el { height: 9px; border-width: 0; }
.weak button .el.dot { width: 9px; background: var(--green); }
.weak button .el.dash { width: 20px; background: var(--red); }
.weak button small { color: var(--silk-dim); font-weight: 500; font-size: 0.8rem; }
.actions { display: flex; gap: 10px; }

.btn {
  appearance: none;
  height: 44px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1.5px solid var(--gold);
  background: none;
  color: var(--gold);
  font-weight: 700;
  cursor: pointer;
}
.btn.primary { background: var(--gold); color: var(--mask); }

.app.is-done .text, .app.is-done .readout { display: none; }
/* The result takes the place of the words and no more: the diagram keeps the
   size it had (see holdBoard), the key becomes the Go again button and the
   shortcut line shows the keys that work now. */
.app.is-done .results { flex: 1 0 auto; }
.actions:not(:has(button:not([hidden]))) { display: none; }
.paddle.again { display: none; touch-action: manipulation; }
.app.is-done #keys > :not(.again) { display: none; }
.app.is-done #keys > .again { display: flex; }

/* ---------- settings sheet ---------- */
.sheet {
  width: min(92vw, 420px);
  max-height: 90vh;
  max-height: 90dvh;
  overflow: hidden;
  background: var(--board);
  color: var(--silk);
  border: 1.5px solid var(--gold);
  border-radius: 16px;
  padding: 0;
}
/* The title bar stays put and only what is under it scrolls, so the scroll
   bar runs beside the list and stops at the title bar. */
.sheet[open] { display: flex; flex-direction: column; }
.sheet > form { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 18px 18px;
  /* A thin gold bar on the sheet's own colour, not the browser's dark track. */
  scrollbar-width: thin;
  scrollbar-color: var(--gold-mid) transparent;
}
/* Course progress holds 26 tiles with two scores each: it takes the room a wide screen has. */
#progress { width: min(92vw, 640px); }
/* On a wide screen the settings take two columns, read down the left and then down the right. */
@media (min-width: 760px) {
  #settings { width: min(92vw, 880px); }
  #options { column-count: 2; column-gap: 40px; column-rule: 1px solid #2c3234; }
  #options fieldset { break-inside: avoid; }
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.7); }
.sheet h2 { margin: 0 0 14px; font-size: 1.15rem; }
.sheet fieldset { border: 0; padding: 0; margin: 0 0 16px; }
.sheet legend { padding: 0; margin-bottom: 7px; color: var(--silk-dim); font-size: 0.9rem; }
.sheet .seg { display: flex; gap: 6px; }
.sheet .seg button {
  appearance: none;
  flex: 1 1 0;
  height: 40px;
  background: none;
  border: 1.5px solid var(--gold-mid);
  border-radius: 8px;
  color: var(--silk);
  cursor: pointer;
}
.sheet .seg button[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--mask); font-weight: 700; }
.sheet .note { margin: 7px 0 0; color: var(--silk-dim); font-size: 0.85rem; line-height: 1.4; }
.sheet .btn { width: 100%; }
.sheet-body > .note { margin: -6px 0 12px; }
.sheet .row { display: flex; gap: 8px; margin-bottom: 10px; }
.sheet .row .btn { flex: 1 1 0; width: auto; padding: 0 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; margin-bottom: 14px; }
.tile {
  appearance: none;
  background: none;
  border: 1.5px solid var(--gold-mid);
  border-radius: 10px;
  padding: 6px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--silk);
  cursor: pointer;
}
.tile b { font-size: 1.2rem; line-height: 1; }
.tile .code { display: flex; align-items: center; gap: 2px; height: 8px; }
.tile .el { height: 6px; border: 0; }
.tile .el.dot { width: 6px; background: var(--green); }
.tile .el.dash { width: 12px; background: var(--red); }
.tile small { font-size: 0.72rem; color: var(--silk-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile.learning { border-style: dashed; }
.tile.learned { border-color: var(--gold); }
.tile.focus { border: 2px solid var(--gold-hot); }
.tile.locked { opacity: 0.35; }
/* Chosen for a drill: filled, as a chosen setting is. */
.tile[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--mask); }
.tile[aria-pressed="true"] small { color: var(--mask); }
.tile[aria-pressed="true"] .el { background: var(--mask); }
.history p { margin: 0 0 6px; color: var(--silk-dim); font-size: 0.9rem; }
.history svg { display: block; width: 100%; height: 40px; margin-bottom: 14px; }
.history polyline { fill: none; stroke: var(--gold); stroke-width: 2; vector-effect: non-scaling-stroke; }

/* A sheet's title and its Done button, above the part that scrolls. */
.sheet-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--gold-mid);
}
.sheet .sheet-head h2 { margin: 0; }
.sheet .sheet-head .btn { width: auto; height: 36px; padding: 0 16px; }
.sheet h3 { margin: 20px 0 0; font-size: 1rem; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 0; color: var(--silk-dim); font-size: 0.9rem; }
.field input {
  appearance: none;
  height: 44px;
  padding: 0 12px;
  background: var(--mask);
  border: 1.5px solid var(--gold-mid);
  border-radius: 8px;
  color: var(--silk);
  font: 1.1rem var(--mono);
}
.field input:focus { border-color: var(--gold); }
.err { margin: 8px 0; min-height: 1.2em; color: var(--red); font-size: 0.9rem; line-height: 1.4; }
.err:empty { min-height: 0; margin: 6px 0; }
.sheet .after { margin-top: 12px; }
.sheet .msg { margin: 2px 0 4px; line-height: 1.5; }
.link-code { margin: 16px 0 6px; text-align: center; font: 700 clamp(1.3rem, 6.4vw, 2.2rem) var(--mono); letter-spacing: 0.1em; white-space: nowrap; color: var(--gold-hot); min-height: 1.3em; }

/* ---------- the stats page ---------- */
.app[data-view] > :not(.top):not(.hub):not(dialog) { display: none; }
.icon-btn[aria-pressed="true"] { background: var(--gold); color: var(--mask); }
/* On the stats page the trainer's mode is not where you are. */
.app[data-view] .modes button[aria-pressed="true"] { background: none; color: var(--gold); }

.hub { flex: 1 1 0; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding-bottom: 20px; }
/* A page that scrolls reaches both edges of the window: the scroll bar sits at
   the window's edge and the wheel works wherever the pointer is. What is on
   the page keeps to its column. */
.hub {
  margin-left: calc(-1 * var(--edge-l));
  margin-right: calc(-1 * var(--edge-r));
  padding-left: var(--edge-l);
  padding-right: var(--edge-r);
  scrollbar-width: thin;
  scrollbar-color: var(--gold-mid) transparent;
}
.hub-body { width: 100%; }
.profile { max-width: 640px; }
.hub-body h2 { margin: 0 0 4px; font-size: 1.5rem; overflow-wrap: anywhere; }
.hub-body h3 { margin: 26px 0 6px; font-size: 1.05rem; color: var(--gold); }
.sub { margin: 0 0 10px; color: var(--silk-dim); font-size: 0.92rem; line-height: 1.45; max-width: 60ch; }
.sub.small { font-size: 0.82rem; margin-top: 12px; }
/* The privacy and terms links sit at the foot of the page, below everything. */
.hub-foot { margin: auto 0 0; padding-top: 24px; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.85rem; }
.hub-foot a { color: var(--silk-dim); text-underline-offset: 3px; }
.hub-foot a:hover { color: var(--silk); }

.chip:disabled, .btn:disabled { opacity: 0.4; cursor: default; }

.hub .seg { display: inline-flex; border: 1.5px solid var(--gold-mid); border-radius: 9px; overflow: hidden; }
.hub .seg button {
  appearance: none;
  height: 34px;
  padding: 0 14px;
  background: none;
  border: 0;
  color: var(--silk-dim);
  font-weight: 700;
  cursor: pointer;
}
.hub .seg button + button { border-left: 1.5px solid var(--gold-mid); }
.hub .seg button[aria-pressed="true"] { background: rgba(214, 171, 82, 0.16); color: var(--gold-hot); }
.profile .seg { margin: 0 0 12px; }
.sub.empty { max-width: none; margin: 0 0 16px; padding: 26px 14px; text-align: center; border: 1px dashed #2c3234; border-radius: 12px; }

.rank { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.rank th { text-align: left; font-weight: 400; color: var(--silk-dim); font-size: 0.82rem; padding: 4px 8px; border-bottom: 1px solid var(--gold-mid); }
.rank td { padding: 9px 8px; border-bottom: 1px solid #23282a; }
.rank td:first-child, .rank th:first-child { width: 3.2em; color: var(--silk-dim); }
.rank.plain td:first-child, .rank.plain th:first-child { width: auto; color: inherit; }
.rank.plain th:first-child { color: var(--silk-dim); }
.rank .num { text-align: right; font-family: var(--mono); white-space: nowrap; }
.rank a { color: var(--silk); text-decoration: none; overflow-wrap: anywhere; }
.rank tr.me td { background: rgba(214, 171, 82, 0.13); }
.rank tr.me td:first-child, .rank tr.me a { color: var(--gold-hot); font-weight: 700; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 18px; margin: 16px 0 4px; }
.stats + .rank { margin-top: 14px; }
.stats div { display: flex; flex-direction: column; }
.stats b { font-size: 1.7rem; line-height: 1.1; color: var(--gold-hot); font-variant-numeric: tabular-nums; }
.stats span { color: var(--silk-dim); font-size: 0.85rem; margin-top: 3px; }
.lit5 { display: inline-flex; gap: 4px; vertical-align: middle; }
.lit5 i { display: grid; place-items: center; width: 1.6em; height: 1.6em; border: 1px solid #2c3234; border-radius: 5px; color: var(--silk-dim); font-style: normal; font-size: 0.78rem; font-weight: 700; }
.lit5 i.on { background: var(--gold); border-color: var(--gold-hot); color: #14110a; }
.tile.still { cursor: default; }
.profile .row { display: flex; flex-wrap: wrap; gap: 8px; }
/* One way of signing in: what it is on the left, its button on the right. */
.way { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; max-width: 520px; margin: 0 0 10px; }
.way .field { flex: 1 1 220px; margin: 0; }
.way > span { flex: 1 1 160px; align-self: center; }
.way + .err { margin-top: -2px; }
.profile .history svg { height: 64px; }
.cal { display: grid; grid-template-rows: repeat(7, 11px); grid-auto-flow: column; grid-auto-columns: 11px; gap: 3px; }
.cal i { border-radius: 2px; background: #1c2021; }
.cal .l1 { background: #5b4a26; }
.cal .l2 { background: #a5843f; }
.cal .l3 { background: var(--gold-hot); }
.cal .future { background: none; }

@media (max-width: 430px) {
  .top { gap: 6px; }
  .mark { font-size: 0.9rem; letter-spacing: 0.03em; gap: 4px; }
  .mark-dash { margin-right: 3px; }
  .icon-btn { width: 34px; }
  .modes button { padding: 0 10px; }
}
@media (min-width: 560px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
  .cal { grid-template-rows: repeat(7, 14px); grid-auto-columns: 14px; }
}

/* ---------- phones ---------- */
/* Daily five, test and course need the room: the two marks stand for the name. */
@media (max-width: 559px) {
  .mark-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
@media (max-width: 359px) {
  .modes button { padding: 0 7px; }
}

/* ---------- short phones ---------- */
@media (max-height: 640px) {
  :root { --fs: 1.3rem; --lh: 1.9rem; }
  .text { height: calc(var(--lh) * 2); }
  .keys { height: 88px; }
}

/* ---------- desktop ---------- */
@media (min-width: 760px) and (min-height: 700px) {
  :root { --fs: 1.9rem; --lh: 2.8rem; }
  .app { gap: 12px; padding-top: 18px; padding-bottom: 14px; }
  .mark { font-size: 1.25rem; }
  .keys { height: 84px; }
  .paddle { flex-direction: row; gap: 14px; }
}
@media (hover: hover) and (pointer: fine) {
  .hints {
    flex: none;
    margin: 0;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px 22px;
    color: var(--silk-dim);
    font-size: 0.9rem;
  }
  kbd {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--silk);
    border: 1px solid var(--gold-mid);
    border-radius: 5px;
    padding: 1px 6px;
    margin-right: 5px;
  }
  .chip:hover:not(:disabled), .weak button:hover, .sheet .seg button:hover, .hub .seg button:hover { border-color: var(--gold); }
  .rank a:hover { text-decoration: underline; }
}

@media (prefers-reduced-motion: reduce) {
  .words { transition: none; }
  .ch.shake, .node.flash-bad, .node.focus .pad { animation: none !important; }
}

/* Send or receive: the same course and test, keyed or heard. */
.config { gap: 8px; }
.dirs { display: flex; flex: none; border: 1.5px solid var(--gold-mid); border-radius: 8px; overflow: hidden; }
.dirs button {
  appearance: none;
  background: none;
  border: 0;
  height: 29px;
  padding: 0 10px;
  color: var(--silk-dim);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.dirs button[aria-pressed="true"] { background: var(--gold-mid); color: var(--silk); }
.chip { white-space: nowrap; }
/* On a phone the switch and the length share a line, and the course's own
   line sits under them. */
@media (max-width: 559px) {
  .config { flex-wrap: wrap; row-gap: 6px; }
  .config #lenBtn { order: 1; margin-left: auto; }
  .config .course-bar, .config .set-lab { order: 2; flex: 1 0 100%; }
}
/* Receiving: nothing is keyed. One button plays the letter, and when the
   diagram is hidden a pad of letters takes the answers. */
.paddle.hear, .keys .letters { display: none; }
.app[data-dir="listen"] .keys .paddle.dot, .app[data-dir="listen"] .keys .paddle.dash,
.app[data-dir="listen"] .keys .paddle.key { display: none; }
.app[data-dir="listen"] .keys .paddle.hear { display: flex; touch-action: manipulation; }
.app[data-dir="listen"][data-tree="hide"] .keys { flex: none; flex-direction: column; height: auto; max-height: none; }
.app[data-dir="listen"][data-tree="hide"] .keys .paddle.hear,
.app[data-dir="listen"][data-tree="hide"] .keys .paddle.again { flex: none; height: 56px; }
.app[data-dir="listen"][data-tree="hide"] .keys .letters { display: grid; grid-template-columns: repeat(auto-fit, minmax(42px, 1fr)); gap: 6px; }
.keys .letters button {
  appearance: none;
  height: 46px;
  background: none;
  border: 1.5px solid var(--gold-mid);
  border-radius: 10px;
  color: var(--silk);
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.keys .letters button.target { border-color: var(--silk); box-shadow: inset 0 0 0 2px var(--silk); }
.app[data-dir="listen"] .hints.for-send, .app:not([data-dir="listen"]) .hints.for-listen { display: none; }
/* Receiving on a phone: no diagram. A tap on the box brings up the phone's
   own keyboard, and the letter heard is typed on it. */
.rx-in { display: none; }
.app.rx-type .board { display: none; }
.app.rx-type[data-dir="listen"] .keys { flex: none; flex-direction: column; height: auto; min-height: 0; max-height: none; }
.app.rx-type[data-dir="listen"] .keys .letters { display: none; }
.app.rx-type[data-dir="listen"] .keys .paddle.hear, .app.rx-type[data-dir="listen"] .keys .paddle.again { flex: none; height: 56px; }
.app.rx-type:not(.is-done) .rx-in {
  display: block;
  appearance: none;
  width: 100%;
  height: 56px;
  padding: 0 14px;
  background: var(--board);
  border: 1.5px solid var(--gold-mid);
  border-radius: 14px;
  color: var(--silk);
  font: inherit;
  /* 16px or more, so an iPhone does not zoom in on the box. */
  font-size: 1rem;
  text-align: center;
  caret-color: var(--gold);
}
.app.rx-type .rx-in:focus { outline: none; border-color: var(--gold); }
/* The keyboard is up and room is short: the switches and the box step aside.
   The box stays in focus, out of sight, so the keyboard stays. */
.app.rx-keys > .config { display: none; }
.app.rx-keys .text { height: calc(var(--lh) * 2); }
.app.rx-keys .keys { position: relative; }
.app.rx-keys .keys .paddle.hear { height: 48px; }
.app.rx-type.rx-keys:not(.is-done) .rx-in { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; pointer-events: none; }
.app.rx-type .rx-in::placeholder { color: var(--silk-dim); }
.hints.for-done, .app.is-done .hints.for-send, .app.is-done .hints.for-listen { display: none; }
@media (hover: hover) and (pointer: fine) {
  .app.is-done .hints.for-done { display: flex; }
}
.tile small.other { opacity: 0.6; }
