/* The online Morse keyboard: a mode switch, the letter being keyed, one keys box, the text, and a row of actions. */
.kbd { display: grid; gap: 16px; margin: 28px 0 0; padding: 24px; border-radius: var(--r-panel); background: var(--panel); box-shadow: var(--shadow); }
.article .kbd h2 { margin: 0; font-size: 26px; }
.article .kbd h3 { margin: 0; font-size: 18px; }
.article .kbd p { margin: 0; }
.article .kbd ul { margin: 0; padding: 0; list-style: none; }
.article .kbd li + li { margin-top: 0; }
.article .kbd .kbd-note { color: var(--sec); font-size: 15px; }
.kbd-app { display: grid; gap: 16px; min-width: 0; }
.kbd-app[hidden] { display: none; }
.kbd kbd { padding: 1px 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); font: inherit; font-size: 14px; line-height: 1.5; white-space: nowrap; }

/* Mode switch: two radios drawn as one segmented control; the checked one is inverted and carries a tick */
.kbd-modes { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0; }
.kbd-modes legend { padding: 0; margin-bottom: 8px; font-size: 14px; color: var(--sec); }
.kbd-mode { position: relative; flex: 1 1 140px; }
.kbd-mode input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.kbd-mode span { display: flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 16px; border-radius: var(--r-cap); background: var(--fill); color: var(--ink); font-size: 17px; font-weight: 600; }
.kbd-mode input:checked + span { background: var(--cta); color: var(--on-cta); }
.kbd-mode input:checked + span::before { content: "\2713\00a0"; }
.kbd-mode input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 3px; }

.kbd-readout { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-width: 0; }
.kbd-letter { display: grid; gap: 6px; min-width: 0; }
.kbd-label { font-size: 14px; color: var(--sec); }
.kbd-letter-row { display: flex; align-items: center; gap: 16px; min-height: 64px; padding: 0 16px; border-radius: var(--r-tile); background: var(--tile); }
.kbd-marks { --u: 12px; display: flex; align-items: center; min-width: 0; min-height: 20px; }
.kbd-marks .code { flex-wrap: wrap; }
.kbd-preview { min-width: 1ch; font-size: 36px; font-weight: 300; line-height: 1; }
.kbd-preview:not(:empty)::before { content: "="; margin-right: 10px; color: var(--sec); }

.kbd-pad { display: grid; gap: 14px; padding: 14px; border: 1.5px solid var(--line); border-radius: var(--r-tile); }
.kbd-panel { display: grid; gap: 14px; min-width: 0; }
.kbd-panel[hidden] { display: none; }
.kbd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kbd .kbd-btn { min-width: 0; min-height: 56px; padding: 8px 14px; gap: 8px; text-align: center; }
/* Fast taps on the buttons must not zoom the page on iPhone or select their labels. The straight key keeps touch-action: none. */
.kbd .kbd-btn, .kbd-mode input { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.kbd .kbd-mark-btn { flex-direction: column; min-height: 104px; background: var(--tile); color: var(--ink); }
.kbd-graphic { --u: 12px; display: flex; align-items: center; justify-content: center; min-height: 24px; }
.kbd-graphic .code { --u: 12px; }
.kbd-btn-label { font-weight: 600; }
.kbd-keys { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--sec); font-size: 15px; }

/* The straight key: big, inverted and labelled while it is down, so the state never rests on colour alone */
.kbd-key {
  display: grid; align-content: center; justify-items: center; gap: 6px; width: 100%; min-height: 160px; padding: 16px;
  border: 2px solid var(--ink); border-radius: var(--r-panel); background: var(--tile); color: var(--ink); cursor: pointer;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none;
  transition: transform 0.08s var(--ease), background-color 0.08s;
}
.kbd-key[data-down] { border-width: 6px; background: var(--y); color: var(--on-y); transform: translateY(3px) scale(0.985); }
.kbd-key-state { font-size: 24px; font-weight: 650; }
.kbd-key-hint { font-size: 15px; color: var(--sec); text-align: center; }
.kbd-key[data-down] .kbd-key-hint { color: var(--on-y); }
.kbd-settings { display: flex; flex-wrap: wrap; gap: 12px; }
.kbd-field { display: grid; flex: 1 1 160px; gap: 4px; min-width: 0; font-size: 14px; color: var(--sec); }
.kbd-field select { min-height: 48px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); font-size: 17px; }

.article .kbd .kbd-status { min-height: 1.5em; font-weight: 600; }
.kbd-result { display: grid; gap: 8px; }
.article .kbd .kbd-text { min-height: 3.6em; padding: 16px 18px; border-radius: var(--r-tile); background: var(--tile); font-size: 22px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.kbd-text:empty::before { content: "Your text appears here."; color: var(--ter); font-size: 17px; }
.kbd-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.kbd-actions .kbd-btn { flex: 1 1 auto; }
.kbd-switch[aria-checked="true"] { background: var(--cta); color: var(--on-cta); }

@media (max-width: 420px) {
  .kbd { padding: 16px; }
  .kbd-readout { gap: 10px; }
  .kbd .lamp { width: 44px; height: 44px; }
}
@media (prefers-reduced-motion: reduce) { .kbd-key { transition: none; } }
