/* Handwriting recognition demo. The lab keeps its own dark look in both
   site themes, so the ink, the feature maps and the sparks read the same. */

main section.hw-section {
	max-width: 1220px;
	padding-top: 2.5rem;
	padding-bottom: 2rem;
}

main section.hw-below {
	padding-top: 0;
	padding-bottom: 4rem;
}

.hw {
	--hw-panel: #18213a;
	--hw-edge: #2a3558;
	--hw-text: #e8ecf8;
	--hw-muted: #9aa4c4;
	--hw-accent: #5eead4;
	--hw-accent-2: #60a5fa;
	--hw-warn: #fbbf24;
	background: linear-gradient(180deg, #0d1220, #131a2e);
	color: var(--hw-text);
	border-radius: 20px;
	padding: 1.5rem;
	box-shadow: var(--shadow);
	outline: none;
	scroll-margin-top: 5.5rem;
}

.hw h2 {
	margin: 0 0 0.6rem;
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--hw-muted);
}

.hw h2.hw-loose {
	margin-top: 0.2rem;
}

.hw h2.hw-big {
	font-size: 1.35rem;
	letter-spacing: 0;
	text-transform: none;
	color: var(--hw-text);
}

.hw button {
	font: inherit;
	cursor: pointer;
}

.hw button:focus-visible,
.hw-pad:focus-visible {
	outline: 3px solid var(--hw-accent);
	outline-offset: 2px;
}

.hw-top {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem 2rem;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 1.25rem;
}

.hw-tabs {
	display: inline-flex;
	padding: 4px;
	border-radius: 12px;
	background: #0a0e1a;
	border: 1px solid var(--hw-edge);
}

.hw-tab {
	padding: 0.5rem 1rem;
	border: 0;
	border-radius: 9px;
	background: none;
	color: var(--hw-muted);
	font-weight: 700;
}

.hw-tab[aria-pressed="true"] {
	background: var(--hw-accent);
	color: #06231f;
}

.hw-scores {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	margin: 0;
}

.hw-scores > div {
	padding: 0.55rem 0.9rem;
	border-radius: 12px;
	background: var(--hw-panel);
	border: 1px solid var(--hw-edge);
}

.hw-scores dt {
	font-size: 0.68rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--hw-muted);
}

.hw-scores dd {
	margin: 0.1rem 0 0;
	font-size: 1rem;
}

.hw-scores i {
	font-style: normal;
	font-weight: 700;
	color: var(--hw-accent);
	margin-left: 0.35rem;
}

.hw-reset {
	margin-left: 0.5rem;
	padding: 0.1rem 0.5rem;
	border-radius: 7px;
	border: 1px solid var(--hw-edge);
	background: none;
	color: var(--hw-muted);
	font-size: 0.75rem;
}

.hw-main {
	display: grid;
	grid-template-columns: minmax(0, 460px) minmax(0, 1fr);
	gap: 1.5rem;
	align-items: start;
}

.hw[data-mode="number"] .hw-main {
	grid-template-columns: minmax(0, 1fr);
}

.hw[data-mode="digit"] .hw-number-only,
.hw[data-mode="number"] .hw-digit-only {
	display: none;
}

.hw-pad {
	display: block;
	width: 100%;
	aspect-ratio: 1;
	border-radius: 18px;
	border: 2px solid var(--hw-edge);
	background: #0a0e1a;
	touch-action: none;
	cursor: crosshair;
	transition: border-color 0.2s ease;
}

.hw[data-mode="number"] .hw-pad {
	aspect-ratio: 3.4;
	min-height: 190px;
}

.hw-has-ink .hw-pad {
	border-color: rgba(94, 234, 212, 0.6);
}

.hw-tools {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.6rem;
	margin-top: 0.8rem;
}

.hw-tools button {
	padding: 0.5rem 0.9rem;
	border-radius: 11px;
	border: 1.5px solid var(--hw-edge);
	background: var(--hw-panel);
	color: var(--hw-text);
	font-weight: 700;
}

.hw-tools button:hover {
	border-color: var(--hw-accent);
}

.hw kbd {
	margin-left: 0.6rem;
	font: 700 0.72rem var(--font-mono);
	color: var(--hw-muted);
}

.hw-went {
	margin: 0 0 0 0.4rem;
	font-size: 0.85rem;
	color: var(--hw-muted);
}

.hw-went b:last-child {
	color: var(--hw-accent);
	font-size: 1.15rem;
}

.hw-status,
.hw-hint {
	margin: 0.7rem 0 0;
	font-size: 0.85rem;
	line-height: 1.5;
	color: var(--hw-muted);
}

.hw-ready .hw-status {
	display: none;
}

.hw-right {
	display: grid;
	gap: 0.9rem;
}

.hw-panel {
	padding: 1rem 1.2rem;
	border-radius: 16px;
	background: var(--hw-panel);
	border: 1px solid var(--hw-edge);
}

.hw-guess {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
}

.hw-guess-row {
	display: flex;
	align-items: center;
	gap: 1.1rem;
}

.hw-guess-digit {
	font-size: 6.2rem;
	font-weight: 700;
	line-height: 1;
	min-width: 0.62em;
	color: #4a5578;
}

.hw-guess-digit[data-level="high"],
.hw-number-digits li[data-level="high"] b { color: var(--hw-accent); }
.hw-guess-digit[data-level="mid"],
.hw-number-digits li[data-level="mid"] b { color: var(--hw-accent-2); }
.hw-guess-digit[data-level="low"],
.hw-number-digits li[data-level="low"] b { color: var(--hw-warn); }

.hw-guess-row p {
	margin: 0;
	display: grid;
	gap: 0.1rem;
	color: var(--hw-muted);
	font-size: 0.95rem;
}

.hw-guess-percent {
	font-size: 2rem;
	color: var(--hw-text);
	line-height: 1.1;
}

.hw-guess-time {
	font-size: 0.75rem;
}

.hw-seen-box {
	text-align: right;
}

.hw-seen {
	width: 112px;
	height: 112px;
	border-radius: 8px;
	image-rendering: pixelated;
}

.hw-judge {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.88rem;
	color: var(--hw-muted);
}

.hw-judge[hidden] {
	display: none;
}

.hw-judge button {
	border-radius: 9px;
	border: 1.5px solid var(--hw-edge);
	background: var(--hw-panel);
	color: var(--hw-text);
	font-weight: 700;
	padding: 0.3rem 0.55rem;
}

.hw-judge .hw-yes {
	border-color: rgba(94, 234, 212, 0.6);
	padding: 0.3rem 0.8rem;
}

.hw-judge button:hover {
	border-color: var(--hw-accent);
}

.hw-actual {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.25rem;
}

.hw-actual > span {
	margin: 0 0.25rem 0 0.4rem;
}

.hw-bars {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 5px;
}

.hw-bar {
	display: grid;
	grid-template-columns: 1.1rem 1fr 2.6rem;
	align-items: center;
	gap: 0.6rem;
	color: var(--hw-muted);
	font-size: 0.8rem;
}

.hw-bar b {
	font-size: 0.95rem;
}

.hw-bar div {
	height: 12px;
	border-radius: 12px;
	background: #202a47;
	overflow: hidden;
}

.hw-bar span {
	display: block;
	height: 100%;
	min-width: 12px;
	border-radius: 12px;
	background: #55618a;
}

.hw-bar i {
	font-style: normal;
}

.hw-bar-best {
	color: var(--hw-text);
}

.hw-bar-best span {
	background: linear-gradient(90deg, var(--hw-accent-2), var(--hw-accent));
}

.hw-votes {
	display: grid;
	grid-template-columns: repeat(6, minmax(0, 1fr));
	gap: 8px;
}

.hw-vote {
	position: relative;
	display: grid;
	gap: 0.15rem;
	min-height: 3.2rem;
	padding: 0.45rem 0.6rem;
	border-radius: 12px;
	background: var(--hw-panel);
	border: 1.5px solid var(--hw-edge);
	font-size: 0.7rem;
	color: var(--hw-muted);
}

.hw-vote[data-state="agree"] { border-color: rgba(94, 234, 212, 0.5); }
.hw-vote[data-state="differ"] { border-color: var(--hw-warn); }
.hw-vote[data-state="differ"] b { color: var(--hw-warn); }

.hw-vote i {
	font-style: normal;
}

.hw-vote b {
	position: absolute;
	right: 0.6rem;
	bottom: 0.3rem;
	font-size: 1.7rem;
	line-height: 1;
	color: var(--hw-text);
}

.hw-flow-panel {
	margin-top: 1.25rem;
}

.hw-flow-scroll {
	overflow-x: auto;
}

.hw-flow {
	display: block;
	width: 100%;
	min-width: 760px;
}

.hw-number-read {
	margin: 0;
	font-size: clamp(3rem, 9vw, 5.5rem);
	font-weight: 700;
	line-height: 1.05;
	letter-spacing: 0.06em;
	color: var(--hw-accent);
	overflow-wrap: anywhere;
}

.hw-number-digits,
.hw-tiles {
	list-style: none;
	margin: 0.8rem 0 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.hw-number-digits li {
	display: grid;
	justify-items: center;
	gap: 0.1rem;
	font-size: 0.75rem;
	color: var(--hw-muted);
}

.hw-number-digits canvas {
	width: 56px;
	height: 56px;
	border-radius: 6px;
	image-rendering: pixelated;
}

.hw-number-digits b {
	font-size: 1.3rem;
	line-height: 1;
}

.hw-mine-wrong {
	margin-top: 1.25rem;
}

.hw-mine-wrong[hidden] {
	display: none;
}

.hw-mistakes {
	margin-bottom: 2.5rem;
}

.hw-tile {
	display: grid;
	justify-items: center;
	gap: 0.35rem;
	padding: 8px 8px 6px;
	border-radius: 12px;
	border: 1.5px solid var(--hw-edge);
	background: var(--hw-panel);
	color: var(--hw-muted);
	font-size: 0.74rem;
}

.hw-tile:hover {
	border-color: var(--hw-accent);
}

.hw-tile canvas {
	width: 84px;
	height: 84px;
	border-radius: 6px;
	image-rendering: pixelated;
}

.hw-tile b {
	color: var(--hw-text);
	font-size: 0.95rem;
}

.hw-tile b + b,
.hw-tile span b:last-of-type {
	color: var(--hw-warn);
}

.hw-tile i {
	font-style: normal;
}

.hw-live {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	margin: 0;
}

.hw-about {
	max-width: 760px;
}

.hw-about h2 {
	margin-top: 0;
}

.hw-about p {
	line-height: 1.7;
	color: var(--text-muted);
}

.hw-about .btn {
	margin: 0.5rem 0.5rem 0 0;
}

@media (max-width: 900px) {
	.hw {
		padding: 1rem;
		border-radius: 16px;
	}

	.hw-main {
		grid-template-columns: minmax(0, 1fr);
	}

	.hw-pad {
		max-width: 460px;
		margin: 0 auto;
	}

	.hw[data-mode="number"] .hw-pad {
		max-width: none;
		aspect-ratio: 2.2;
	}

	.hw-guess-digit {
		font-size: 4.6rem;
	}

	.hw-seen,
	.hw-seen-box h2 {
		display: none;
	}

	.hw-votes {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}
