/**
 * CW Forge — console interface
 *
 * Sibling to Antenna Forge: same dark ground, same family, but built on a
 * retro control-console vocabulary — elbow columns, pill buttons, lit lamp
 * toggles, segmented meters and letter-spaced caps.
 *
 * @package CWForge
 */

.cw-forge {
	--cwf-bg: #05090f;
	--cwf-panel: #0b1220;
	--cwf-panel-2: #111c30;
	--cwf-ink: #e8f2fa;
	--cwf-muted: #8aa2b4;
	--cwf-line: rgba(140, 190, 225, 0.18);

	/* Console palette, tuned down slightly so it sits on a dark ground. */
	--cwf-orange: #ff9c3a;
	--cwf-gold: #ffc857;
	--cwf-lilac: #b79cff;
	--cwf-sky: #6cc6ff;
	--cwf-blue: #6f8dff;
	--cwf-green: #4fd88a;
	--cwf-red: #ff6b6b;

	position: relative;
	box-sizing: border-box;
	width: 100%;
	margin: 28px auto;
	border-radius: 20px;
	background:
		radial-gradient(circle at 88% -8%, rgba(108, 198, 255, 0.14), transparent 34%),
		linear-gradient(160deg, #060c15, var(--cwf-bg));
	color: var(--cwf-ink);
	font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
	line-height: 1.55;
	overflow: hidden;
}

.cw-forge *,
.cw-forge *::before,
.cw-forge *::after { box-sizing: border-box; }

.cw-forge [hidden] { display: none !important; }

.cw-forge__loading { padding: 64px 24px; text-align: center; color: var(--cwf-muted); }

/* ---------- shell: the elbow column ---------- */

.cwf-shell {
	display: grid;
	grid-template-columns: 132px 1fr;
	gap: 0;
	min-height: 640px;
}

.cwf-rail {
	display: flex;
	flex-direction: column;
	gap: 7px;
	padding: 18px 0 18px 18px;
}

/* The elbow: a fat rounded corner sweeping into the content area.
   It used to carry a small horizontal spur off its bottom-right, which read
   as a chunk bitten out of the block once the mark sat beside it. Clean
   rectangle now — the rail keeps its console silhouette without the notch. */
.cwf-rail__elbow {
	height: 92px;
	border-radius: 46px 8px 12px 12px;
	background: var(--cwf-orange);
}

.cwf-rail__block {
	border-radius: 12px 4px 4px 12px;
	min-height: 26px;
}

.cwf-rail__block--a { background: var(--cwf-gold); flex: 0 0 54px; }
.cwf-rail__block--b { background: var(--cwf-lilac); flex: 0 0 30px; }
.cwf-rail__block--c { background: var(--cwf-sky); flex: 1 1 auto; }
.cwf-rail__block--d { background: var(--cwf-blue); flex: 0 0 78px; }
.cwf-rail__block--e { background: var(--cwf-red); flex: 0 0 22px; }

.cwf-rail__stamp {
	padding: 8px 10px 0 2px;
	color: var(--cwf-muted);
	font-size: 10px;
	font-weight: 800;
	letter-spacing: 1.6px;
	text-align: right;
	text-transform: uppercase;
}

.cwf-body { padding: 18px 22px 24px 16px; min-width: 0; }

/* ---------- header ---------- */

.cwf-head {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 14px;
	padding-bottom: 14px;
	border-bottom: 2px solid var(--cwf-line);
}

.cwf-head__title { display: flex; align-items: center; gap: 16px; min-width: 0; }

.cwf-head__words { display: block; min-width: 0; }

/* The key mark. Frame deliberately identical to Antenna Forge's so the two
   apps read as one family; only the glyph inside differs. */
.cwf-brandmark {
	display: grid;
	place-items: center;
	flex: 0 0 auto;
	width: 54px;
	height: 54px;
	border: 1px solid rgba(108, 198, 255, 0.45);
	border-radius: 16px;
	background: linear-gradient(145deg, rgba(108, 198, 255, 0.2), rgba(108, 198, 255, 0.04));
	box-shadow: inset 0 0 24px rgba(108, 198, 255, 0.08);
	color: var(--cwf-sky);
}

.cwf-brandmark svg { display: block; width: 36px; height: 36px; }

.cwf-eyebrow {
	margin: 0 0 2px;
	color: var(--cwf-sky);
	font-size: 10px;
	font-weight: 800;
	letter-spacing: 0.19em;
	text-transform: uppercase;
}

@media (max-width: 640px) {
	.cwf-head__title { align-items: flex-start; }
	.cwf-brandmark { width: 45px; height: 45px; border-radius: 12px; }
	.cwf-brandmark svg { width: 30px; height: 30px; }
}

/* Type scale lifted verbatim from Antenna Forge so the two headers set
   identically: same size ramp, same weight, same negative tracking. */
.cwf-head h2 {
	margin: 0;
	font-size: clamp(24px, 3vw, 36px);
	font-weight: 780;
	/* Antenna Forge sets its sentence-case title tight at -0.035em. Capitals
	   need the opposite treatment or they jam together, so this is the small
	   positive tracking that reads as the same weight of type — not the 2px
	   sprawl it had before. */
	letter-spacing: 0.015em;
	line-height: 1.1;
	text-transform: uppercase;
	color: var(--cwf-gold);
}

.cwf-head__sub {
	margin: 6px 0 0;
	color: var(--cwf-muted);
	font-size: 14px;
	font-weight: 400;
	letter-spacing: normal;
	text-transform: none;
}

.cwf-chip {
	padding: 8px 13px;
	border: 1px solid var(--cwf-line);
	border-radius: 999px;
	color: var(--cwf-muted);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: normal;
	text-transform: none;
	white-space: nowrap;
}

@media (max-width: 640px) { .cwf-chip { display: none; } }

/* ---------- mode tabs ---------- */

.cwf-modes {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 16px 0 18px;
}

.cwf-modes button {
	appearance: none;
	padding: 11px 22px;
	border: 0;
	border-radius: 999px;
	background: var(--cwf-panel-2);
	color: var(--cwf-muted);
	font: inherit;
	font-size: 12px;
	font-weight: 800;
	letter-spacing: 1.8px;
	text-transform: uppercase;
	cursor: pointer;
	transition: background 0.16s ease, color 0.16s ease;
}

.cwf-modes button:hover { background: #1a2942; color: var(--cwf-ink); }

.cwf-modes button[aria-selected="true"] {
	background: var(--cwf-orange);
	color: #10161f;
}

.cwf-modes button:focus-visible {
	outline: 3px solid var(--cwf-sky);
	outline-offset: 2px;
}

/* ---------- panels and cards ---------- */

.cwf-panel { animation: cwf-fade 0.22s ease; }

@keyframes cwf-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.cwf-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
	gap: 14px;
}

.cwf-card {
	position: relative;
	padding: 18px 18px 16px;
	border: 1px solid var(--cwf-line);
	border-radius: 6px 18px 18px 6px;
	background: linear-gradient(180deg, var(--cwf-panel), #080e18);
}

.cwf-card--wide { grid-column: 1 / -1; }

.cwf-card::before {
	content: "";
	position: absolute;
	top: 14px;
	bottom: 14px;
	left: 0;
	width: 5px;
	border-radius: 0 4px 4px 0;
	background: var(--cwf-lilac);
}

.cwf-card--gold::before { background: var(--cwf-gold); }
.cwf-card--sky::before { background: var(--cwf-sky); }
.cwf-card--green::before { background: var(--cwf-green); }

.cwf-card h3,
.cwf-card h4 {
	margin: 0 0 12px;
	font-size: 12px;
	font-weight: 800;
	letter-spacing: 2.2px;
	text-transform: uppercase;
	color: var(--cwf-sky);
}

/* ---------- the copy area ---------- */

.cwf-stage {
	display: grid;
	gap: 12px;
	margin-bottom: 14px;
}

.cwf-readout {
	min-height: 108px;
	padding: 18px 20px;
	border: 1px solid var(--cwf-line);
	border-radius: 6px 18px 18px 6px;
	background: #030710;
	color: var(--cwf-green);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: clamp(20px, 2.6vw, 30px);
	font-weight: 700;
	letter-spacing: 4px;
	word-break: break-word;
}

.cwf-readout--sent { color: var(--cwf-gold); }
.cwf-readout small {
	display: block;
	margin-bottom: 8px;
	color: var(--cwf-muted);
	font-family: inherit;
	font-size: 11px;
	font-weight: 800;
	letter-spacing: 2.2px;
	text-transform: uppercase;
}

.cwf-input {
	width: 100%;
	padding: 16px 18px;
	border: 1px solid var(--cwf-line);
	border-radius: 6px 18px 18px 6px;
	background: #060d18;
	color: var(--cwf-ink);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: clamp(18px, 2.2vw, 24px);
	letter-spacing: 4px;
	text-transform: uppercase;
}

.cwf-input:focus-visible { outline: 3px solid var(--cwf-sky); outline-offset: 1px; }

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

.cwf-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(232px, 100%), 1fr)); gap: 16px 18px; align-items: start; }
.cwf-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cwf-field--wide { grid-column: 1 / -1; }

.cwf-field label {
	color: var(--cwf-muted);
	font-size: 10.5px;
	font-weight: 800;
	letter-spacing: 1.8px;
	text-transform: uppercase;
}

.cwf-field small { color: #6f8598; font-size: 11px; letter-spacing: 0.2px; }

.cwf-field select,
.cwf-field input[type="number"],
.cwf-field input[type="text"] {
	padding: 10px 12px;
	border: 1px solid var(--cwf-line);
	border-radius: 999px;
	background: #0a1322;
	color: var(--cwf-ink);
	font: inherit;
	font-size: 14px;
}

.cwf-range { display: flex; align-items: center; gap: 12px; }

/* Ranges have to be drawn by hand. accent-color alone leaves the browser's
   default track, which is near-white and reads as a broken input on a dark
   panel. Both vendor prefixes are needed; there is still no standard way. */
.cwf-range input[type="range"] {
	flex: 1 1 auto;
	min-width: 0;
	height: 22px;
	margin: 0;
	appearance: none;
	-webkit-appearance: none;
	background: transparent;
	cursor: pointer;
}

.cwf-range input[type="range"]::-webkit-slider-runnable-track {
	height: 6px;
	border-radius: 999px;
	background: #1c2b42;
	border: 1px solid var(--cwf-line);
}
.cwf-range input[type="range"]::-moz-range-track {
	height: 6px;
	border-radius: 999px;
	background: #1c2b42;
	border: 1px solid var(--cwf-line);
}
.cwf-range input[type="range"]::-webkit-slider-thumb {
	appearance: none;
	-webkit-appearance: none;
	width: 18px;
	height: 18px;
	margin-top: -7px;
	border: 0;
	border-radius: 999px;
	background: var(--cwf-orange);
	box-shadow: 0 0 10px rgba(255, 156, 58, 0.5);
}
.cwf-range input[type="range"]::-moz-range-thumb {
	width: 18px;
	height: 18px;
	border: 0;
	border-radius: 999px;
	background: var(--cwf-orange);
	box-shadow: 0 0 10px rgba(255, 156, 58, 0.5);
}
.cwf-range input[type="range"]:focus-visible { outline: 3px solid var(--cwf-sky); outline-offset: 4px; }

/* A button sitting in a field column should not fold onto two lines. */
.cwf-field .cwf-btn { align-self: start; white-space: nowrap; }

/* A full-width field spans the card, but its control should not: a select
   stretched across 1200px of panel reads as a layout mistake. */
.cwf-field--wide select,
.cwf-field--wide input[type="text"],
.cwf-field--wide input[type="number"] { max-width: 520px; }
.cwf-range output {
	min-width: 62px;
	color: var(--cwf-gold);
	font-size: 13px;
	font-weight: 800;
	letter-spacing: 1px;
	text-align: right;
}

.cwf-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.cwf-btn {
	appearance: none;
	padding: 13px 26px;
	border: 0;
	border-radius: 999px;
	background: var(--cwf-gold);
	color: #10161f;
	font: inherit;
	font-size: 12.5px;
	font-weight: 800;
	letter-spacing: 1.8px;
	text-transform: uppercase;
	cursor: pointer;
	transition: filter 0.16s ease;
}

.cwf-btn:hover { filter: brightness(1.12); }
.cwf-btn:focus-visible { outline: 3px solid var(--cwf-sky); outline-offset: 2px; }
.cwf-btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.cwf-btn--ghost { background: var(--cwf-panel-2); color: var(--cwf-ink); }
.cwf-btn--sky { background: var(--cwf-sky); }
.cwf-btn--red { background: var(--cwf-red); color: #180a0a; }

/* ---------- stat tiles ---------- */

.cwf-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(132px, 100%), 1fr)); gap: 10px; margin-bottom: 14px; }

.cwf-stat {
	padding: 12px 14px;
	border: 1px solid var(--cwf-line);
	border-radius: 6px 16px 16px 6px;
	background: var(--cwf-panel);
}

.cwf-stat span {
	display: block;
	color: var(--cwf-muted);
	font-size: 10px;
	font-weight: 800;
	letter-spacing: 1.6px;
	text-transform: uppercase;
}

.cwf-stat strong {
	display: block;
	margin-top: 4px;
	color: var(--cwf-gold);
	font-size: clamp(19px, 2.4vw, 26px);
	font-weight: 800;
	letter-spacing: 1px;
}

/* ---------- fist scorecard ---------- */

.cwf-score { display: grid; gap: 10px; }

.cwf-score__row { display: grid; grid-template-columns: 122px 1fr 56px; align-items: center; gap: 10px; }

.cwf-score__label { color: var(--cwf-muted); font-size: 11px; font-weight: 800; letter-spacing: 1.4px; text-transform: uppercase; }

.cwf-score__track { height: 14px; border-radius: 999px; background: #0d1729; overflow: hidden; }

.cwf-score__fill { height: 100%; border-radius: 999px; background: var(--cwf-green); transition: width 0.3s ease, background 0.3s ease; }
.cwf-score__fill--mid { background: var(--cwf-gold); }
.cwf-score__fill--low { background: var(--cwf-red); }

.cwf-score__value { color: var(--cwf-ink); font-size: 13px; font-weight: 800; text-align: right; }

.cwf-verdict {
	margin-top: 12px;
	padding: 12px 14px;
	border-left: 4px solid var(--cwf-gold);
	border-radius: 0 12px 12px 0;
	background: rgba(255, 200, 87, 0.09);
	font-size: 13.5px;
}

/* Outcome colouring, so a result is readable before it is read. */
.cwf-verdict--good { border-left-color: var(--cwf-green); background: rgba(79, 216, 138, 0.10); }
.cwf-verdict--fair { border-left-color: var(--cwf-gold); background: rgba(255, 200, 87, 0.10); }
.cwf-verdict--poor { border-left-color: var(--cwf-red); background: rgba(255, 107, 107, 0.10); }

/* A spoken target, deliberately not readable until it has been sent. */
.cwf-hidden-target { color: var(--cwf-muted); letter-spacing: 10px; }

/* ---------- character heatmap ---------- */

.cwf-heat { display: flex; flex-wrap: wrap; gap: 6px; }

.cwf-heat__cell {
	display: grid;
	place-items: center;
	width: 42px;
	height: 42px;
	border-radius: 6px 12px 12px 6px;
	background: #101d31;
	color: var(--cwf-ink);
	font-family: ui-monospace, Menlo, Consolas, monospace;
	font-size: 15px;
	font-weight: 800;
}

.cwf-heat__cell small { display: block; font-size: 9px; font-weight: 700; opacity: 0.75; }

/* ---------- mic meter ---------- */

.cwf-meter { height: 10px; border-radius: 999px; background: #0d1729; overflow: hidden; margin-top: 8px; }
.cwf-meter__fill { height: 100%; width: 0; background: var(--cwf-sky); transition: width 0.08s linear; }

.cwf-key {
	display: inline-grid;
	place-items: center;
	width: 74px;
	height: 74px;
	border-radius: 50%;
	background: #0d1729;
	border: 3px solid var(--cwf-line);
	color: var(--cwf-muted);
	font-size: 11px;
	font-weight: 800;
	letter-spacing: 1.4px;
	text-transform: uppercase;
	transition: background 0.05s linear, color 0.05s linear, border-color 0.05s linear;
}

.cwf-key--down { background: var(--cwf-green); border-color: #bcffd8; color: #04140b; }

.cwf-note {
	padding: 11px 13px;
	border-left: 4px solid var(--cwf-sky);
	border-radius: 0 12px 12px 0;
	background: rgba(108, 198, 255, 0.08);
	font-size: 13px;
}

.cwf-note--warn { border-left-color: var(--cwf-red); background: rgba(255, 107, 107, 0.09); }

.cwf-foot {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 10px;
	margin-top: 18px;
	padding-top: 14px;
	border-top: 2px solid var(--cwf-line);
	color: var(--cwf-muted);
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 1.4px;
	text-transform: uppercase;
}

.cwf-foot a { color: var(--cwf-sky); }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
	.cwf-shell { grid-template-columns: 74px 1fr; min-height: 0; }
	.cwf-rail { padding: 14px 0 14px 12px; }
	.cwf-rail__elbow { height: 66px; border-top-left-radius: 34px; }
	.cwf-rail__stamp { display: none; }
	.cwf-body { padding: 14px 16px 20px 12px; }
	.cwf-score__row { grid-template-columns: 100px 1fr 48px; }
}

@media (max-width: 560px) {
	.cw-forge { margin: 16px auto; border-radius: 14px; }
	.cwf-shell { grid-template-columns: 44px 1fr; }
	.cwf-rail { padding: 10px 0 10px 8px; gap: 5px; }
	.cwf-rail__elbow { height: 48px; border-top-left-radius: 24px; }
	.cwf-rail__elbow::after { display: none; }
	.cwf-body { padding: 12px 12px 18px 10px; }
	.cwf-modes button { flex: 1 1 auto; padding: 11px 12px; font-size: 11px; letter-spacing: 1.2px; }
	.cwf-readout { letter-spacing: 3px; }
	.cwf-btn { flex: 1 1 auto; text-align: center; }
	.cwf-heat__cell { width: 38px; height: 38px; }
	.cwf-score__row { grid-template-columns: 84px 1fr 44px; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
	.cw-forge *,
	.cw-forge *::before,
	.cw-forge *::after {
		animation-duration: 0.01ms !important;
		transition-duration: 0.01ms !important;
	}
}

@media print {
	.cw-forge { background: #fff; color: #000; }
	.cwf-rail, .cwf-modes, .cwf-actions { display: none !important; }
	.cwf-card, .cwf-stat { background: #fff; border-color: #999; }
	.cwf-shell { grid-template-columns: 1fr; }
}

/* Header right-hand cluster: help link plus version chip. */
.cwf-head__aside { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cwf-help { padding: 9px 18px; font-size: 11.5px; text-decoration: none; display: inline-block; }
.cwf-help:hover { color: var(--cwf-ink); text-decoration: none; }
@media (max-width: 560px) { .cwf-head__aside { width: 100%; } }

/* ---------- A two-way contact ---------- */

.cwf-qso {
	max-height: 340px;
	margin-top: 14px;
	padding: 14px 16px;
	overflow-y: auto;
	border: 1px solid var(--cwf-line);
	border-radius: 6px 18px 18px 6px;
	background: #030710;
}

.cwf-qso__line {
	display: grid;
	grid-template-columns: 54px 1fr;
	gap: 10px;
	align-items: baseline;
	padding: 7px 0;
	border-bottom: 1px solid rgba(140, 190, 225, 0.08);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 14px;
	line-height: 1.5;
	word-break: break-word;
}

.cwf-qso__line:last-child { border-bottom: 0; }

.cwf-qso__who {
	font-size: 10px;
	font-weight: 800;
	letter-spacing: 1.4px;
	font-family: Inter, system-ui, sans-serif;
}

.cwf-qso__line--them .cwf-qso__who { color: var(--cwf-sky); }
.cwf-qso__line--them .cwf-qso__text { color: var(--cwf-sky); }
.cwf-qso__line--you .cwf-qso__who { color: var(--cwf-gold); }
.cwf-qso__line--you .cwf-qso__text { color: var(--cwf-gold); }

.cwf-qso__note {
	grid-column: 2;
	font-family: Inter, system-ui, sans-serif;
	font-size: 11px;
}

.cwf-qso + .cwf-verdict code,
.cwf-verdict code {
	display: inline-block;
	margin-top: 4px;
	padding: 4px 8px;
	border-radius: 5px;
	background: #030710;
	color: var(--cwf-green);
	font-size: 12.5px;
	letter-spacing: 1px;
}

/* ---------- Parks and summits: the log sheet ---------- */

.cwf-togs--tight { grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); }

.cwf-logsheet {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(215px, 100%), 1fr));
	gap: 14px;
	margin-top: 16px;
}

.cwf-logrow label {
	display: block;
	margin-bottom: 6px;
	color: var(--cwf-sky);
	font-size: 11px;
	font-weight: 800;
	letter-spacing: 1.6px;
	text-transform: uppercase;
}

.cwf-logrow input {
	width: 100%;
	padding: 12px 14px;
	border: 1px solid var(--cwf-line);
	border-radius: 4px 14px 14px 4px;
	background: #060d18;
	color: var(--cwf-green);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 18px;
	letter-spacing: 2px;
	text-transform: uppercase;
}

.cwf-logrow input:focus-visible { outline: 3px solid var(--cwf-sky); outline-offset: 1px; }
.cwf-logrow small { display: block; margin-top: 5px; color: var(--cwf-muted); font-size: 11px; }

.cwf-logresult { margin: 10px 0 0; padding-left: 18px; }
.cwf-logresult li { margin-bottom: 5px; }
.cwf-logresult code {
	padding: 1px 6px;
	border-radius: 4px;
	background: #030710;
	font-size: 13px;
	letter-spacing: 1px;
}
.cwf-ok { color: var(--cwf-green); font-weight: 800; }
.cwf-no { color: var(--cwf-red); font-weight: 800; }

/* ---------- Listen: follow-along text ---------- */

.cwf-textarea {
	width: 100%;
	padding: 14px 16px;
	border: 1px solid var(--cwf-line);
	border-radius: 6px 16px 16px 6px;
	background: #060d18;
	color: var(--cwf-ink);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 15px;
	line-height: 1.6;
	resize: vertical;
}

.cwf-listen {
	max-height: 320px;
	margin-top: 14px;
	padding: 18px 20px;
	overflow-y: auto;
	border: 1px solid var(--cwf-line);
	border-radius: 6px 18px 18px 6px;
	background: #030710;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: clamp(16px, 1.8vw, 21px);
	line-height: 2;
	word-break: break-word;
}

.cwf-listen__empty { color: var(--cwf-muted); font-family: inherit; font-style: normal; }
.cwf-listen__tok { padding: 2px 1px; border-radius: 3px; color: var(--cwf-muted); transition: color 0.1s ease; }
.cwf-listen__sp { display: inline-block; width: 0.55em; }
/* Characters with no Morse equivalent are passed over, and it should be
   obvious that they were skipped rather than missed. */
.cwf-listen__tok.is-skip { opacity: 0.35; text-decoration: line-through; }
.cwf-listen__tok.is-done { color: var(--cwf-green); }
.cwf-listen__tok.is-now {
	background: var(--cwf-gold);
	color: #241a03;
	box-shadow: 0 0 16px rgba(255, 200, 87, 0.45);
}

.cwf-listen__bar {
	height: 7px;
	margin-top: 12px;
	border-radius: 999px;
	background: #16233a;
	overflow: hidden;
}

.cwf-listen__bar span {
	display: block;
	width: 0;
	height: 100%;
	border-radius: 999px;
	background: linear-gradient(90deg, var(--cwf-sky), var(--cwf-gold));
}

/* ---------- signal artifacts: toggles and S-meters ---------- */

.cwf-togs {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(215px, 100%), 1fr));
	gap: 8px;
	margin: 14px 0 4px;
}

/* A console control reads as a lit block, not a checkbox: the lamp on the
   left carries the state and the whole pill is the hit target. */
.cwf-tog {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 16px 10px 12px;
	border: 0;
	border-radius: 999px 8px 8px 999px;
	background: var(--cwf-panel-2);
	color: var(--cwf-muted);
	font: inherit;
	text-align: left;
	cursor: pointer;
	transition: background 0.16s ease, color 0.16s ease;
}

.cwf-tog:hover { background: #1a2942; color: var(--cwf-ink); }
.cwf-tog:focus-visible { outline: 3px solid var(--cwf-sky); outline-offset: 2px; }

.cwf-tog__lamp {
	flex: 0 0 auto;
	width: 15px;
	height: 30px;
	border-radius: 999px;
	background: #24344d;
	transition: background 0.16s ease, box-shadow 0.16s ease;
}

.cwf-tog__text {
	display: block;
	font-size: 12px;
	font-weight: 800;
	letter-spacing: 1.5px;
	text-transform: uppercase;
	line-height: 1.25;
}

.cwf-tog__text small {
	display: block;
	margin-top: 2px;
	color: var(--cwf-muted);
	font-size: 10.5px;
	font-weight: 600;
	letter-spacing: 0.4px;
	text-transform: none;
}

.cwf-tog[aria-pressed="true"] { background: #24344d; color: var(--cwf-ink); }
.cwf-tog[aria-pressed="true"] .cwf-tog__lamp {
	background: var(--cwf-orange);
	box-shadow: 0 0 14px rgba(255, 156, 58, 0.55);
}
.cwf-tog[aria-pressed="true"] .cwf-tog__text small { color: var(--cwf-gold); }

.cwf-smeters {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
	gap: 18px;
	margin-top: 18px;
}

.cwf-smeter__head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: 7px;
	color: var(--cwf-sky);
	font-size: 11px;
	font-weight: 800;
	letter-spacing: 2px;
	text-transform: uppercase;
}

.cwf-smeter__head output { color: var(--cwf-gold); font-size: 13px; }

.cwf-smeter__bar { display: flex; gap: 3px; }

.cwf-seg {
	flex: 1 1 0;
	min-width: 0;
	padding: 9px 2px;
	border: 0;
	background: #16233a;
	color: var(--cwf-muted);
	font: inherit;
	font-size: 10.5px;
	font-weight: 800;
	letter-spacing: 0.5px;
	cursor: pointer;
	transition: background 0.14s ease, color 0.14s ease;
}

.cwf-smeter__bar .cwf-seg:first-child { border-radius: 999px 3px 3px 999px; }
.cwf-smeter__bar .cwf-seg:last-child { border-radius: 3px 999px 999px 3px; }
.cwf-seg:hover { background: #24344d; color: var(--cwf-ink); }
.cwf-seg:focus-visible { outline: 3px solid var(--cwf-sky); outline-offset: 2px; }

/* Lit segments ramp green to red the way a real meter does. */
.cwf-seg--lit { background: var(--cwf-green); color: #06210f; }
.cwf-seg--lit[data-sval="5"], .cwf-seg--lit[data-sval="6"] { background: var(--cwf-gold); color: #241a03; }
.cwf-seg--lit[data-sval="7"], .cwf-seg--lit[data-sval="8"] { background: var(--cwf-orange); color: #241203; }
.cwf-seg--lit[data-sval="9"] { background: var(--cwf-red); color: #2a0808; }

.cwf-seg[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--cwf-ink); }

.cwf-smeter__hint {
	display: block;
	margin-top: 7px;
	color: var(--cwf-muted);
	font-size: 11.5px;
	line-height: 1.45;
}

@media (max-width: 560px) {
	.cwf-seg { font-size: 9px; padding: 8px 1px; }
	.cwf-tog__text small { display: none; }
}

/* Element strip — each mark drawn to scale with the call the decoder made */
.cwf-elements { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 12px 0 4px; }
.cwf-elements:empty { display: none; }
.cwf-mk { display: block; height: 14px; border-radius: 3px; }
.cwf-mk--dit { background: #4fd88a; }
.cwf-mk--dah { background: #6cc6ff; }
.cwf-mk--warn { background: #ff9c3a; box-shadow: 0 0 0 1px rgba(255,156,58,.45); }

/* Key Coach diagnostic readout */
.cwf-diag {
	margin: 12px 0 0;
	padding: 14px 16px;
	max-height: 320px;
	overflow: auto;
	border: 1px solid var(--cwf-line);
	border-radius: 6px 14px 14px 6px;
	background: #02060d;
	color: #8ff0bb;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 12px;
	line-height: 1.6;
	white-space: pre-wrap;
	word-break: break-word;
}

/* ---------- Morse reference chart ---------- */

.cwf-refgrid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(120px, 100%), 1fr));
	gap: 8px;
}

.cwf-ref {
	appearance: none;
	display: grid;
	gap: 5px;
	padding: 12px 10px;
	border: 1px solid var(--cwf-line);
	border-radius: 6px 14px 14px 6px;
	background: #0c1626;
	color: var(--cwf-ink);
	font: inherit;
	text-align: center;
	cursor: pointer;
	transition: background 0.14s ease, border-color 0.14s ease, transform 0.08s ease;
}

.cwf-ref:hover { background: #14243c; border-color: var(--cwf-sky); }
.cwf-ref:active { transform: scale(0.97); }
.cwf-ref:focus-visible { outline: 3px solid var(--cwf-sky); outline-offset: 2px; }

.cwf-ref__char {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 21px;
	font-weight: 800;
	line-height: 1;
	color: var(--cwf-gold);
	letter-spacing: 1px;
}

.cwf-ref__pat {
	display: flex;
	align-items: center;
	justify-content: center;
	/* Six-element patterns such as the apostrophe otherwise run past the cell. */
	flex-wrap: wrap;
	gap: 3px 4px;
	min-height: 12px;
}

/* Blocks read faster than dots and dashes at this size. */
.cwf-el { display: block; height: 7px; border-radius: 4px; background: var(--cwf-green); }
.cwf-el--dit { width: 7px; }
.cwf-el--dah { width: 18px; }

.cwf-ref__dots {
	font-family: ui-monospace, Menlo, Consolas, monospace;
	word-break: break-all;
	font-size: 11px;
	letter-spacing: 2px;
	color: var(--cwf-muted);
}

.cwf-ref__meaning {
	font-size: 10.5px;
	line-height: 1.35;
	color: var(--cwf-sky);
}

/* Below this the rail is taking a fifth of the screen; shrink it hard so the
   content has somewhere to live. The colour blocks still read as the rail. */
@media (max-width: 420px) {
	.cwf-shell { grid-template-columns: 44px 1fr; }
	.cwf-rail { padding: 10px 0 10px 8px; gap: 5px; }
	.cwf-rail__elbow { height: 44px; border-top-left-radius: 22px; }
	.cwf-body { padding: 12px 10px 16px 8px; }
	.cwf-card { padding: 14px 12px 12px; }
}

@media (max-width: 560px) {
	.cwf-refgrid { grid-template-columns: repeat(auto-fill, minmax(min(88px, 100%), 1fr)); gap: 6px; }
	.cwf-ref { padding: 10px 6px; }
	.cwf-ref__char { font-size: 18px; }
	.cwf-el--dah { width: 15px; }
}

/* The chart is worth printing and pinning up next to the key. */
@media print {
	.cwf-panel:not([data-panel="reference"]) { display: none !important; }
	.cwf-refgrid { grid-template-columns: repeat(6, 1fr); }
	.cwf-ref { background: #fff; border-color: #999; break-inside: avoid; }
	.cwf-ref__char { color: #000; }
	.cwf-el { background: #000; }
	.cwf-ref__dots, .cwf-ref__meaning { color: #333; }
}

/* Live key-state view — the operator can see what the app sees. */
.cwf-scope {
	display: block;
	width: 100%;
	height: auto;
	max-height: 130px;
	border: 1px solid var(--cwf-line);
	border-radius: 6px 14px 14px 6px;
	background: #02060d;
}
