:root {
	--bg: #f4f6f8;
	--surface: #ffffff;
	--text: #14202b;
	--muted: #5b6b7a;
	--border: #dde3ea;
	--accent: #0d7a6f;
	--accent-ink: #ffffff;
	--accent-soft: #e3f3f1;
	--warn: #a4510a;
	--warn-soft: #fdf0e3;
	--focus: #2f7de1;
	--radius: 16px;
	--shadow: 0 1px 2px rgb(20 32 43 / 0.06), 0 4px 16px rgb(20 32 43 / 0.06);
	color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0f1419;
		--surface: #182028;
		--text: #e8eef3;
		--muted: #93a3b2;
		--border: #2a3540;
		--accent: #3cc4b2;
		--accent-ink: #062320;
		--accent-soft: #13332f;
		--warn: #f2a65a;
		--warn-soft: #3a2614;
		--focus: #6aa8ff;
		--shadow: 0 1px 2px rgb(0 0 0 / 0.4);
	}
}

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

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	font-size: 16px;
	line-height: 1.45;
}

.wrap {
	max-width: 28rem;
	margin: 0 auto;
	padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
		max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
	display: grid;
	gap: 14px;
}

.masthead h1 {
	margin: 4px 0 2px;
	font-size: 1.5rem;
	font-weight: 700;
	letter-spacing: -0.01em;
}

.sub {
	margin: 0;
	color: var(--muted);
	font-size: 0.95rem;
}

.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 16px;
}

/* Inputs */
.inputs {
	display: grid;
	gap: 16px;
}

.field > label,
.label-row > label {
	display: block;
	font-weight: 600;
	font-size: 0.95rem;
	margin-bottom: 6px;
}

.label-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 6px;
}

.label-row > label {
	margin-bottom: 0;
}

.control {
	position: relative;
	display: flex;
	align-items: center;
}

.control input {
	width: 100%;
	min-height: 48px;
	padding: 10px 64px 10px 14px;
	font: inherit;
	font-size: 1.25rem;
	font-variant-numeric: tabular-nums;
	color: var(--text);
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 12px;
	appearance: none;
}

.control input::placeholder {
	color: var(--muted);
	opacity: 0.55;
}

.control input:focus {
	outline: 2px solid var(--focus);
	outline-offset: 1px;
	border-color: transparent;
}

.suffix {
	position: absolute;
	right: 14px;
	color: var(--muted);
	font-size: 1rem;
	pointer-events: none;
}

.help {
	margin: 6px 0 0;
	color: var(--muted);
	font-size: 0.8rem;
}

/* Segmented toggle (radio inputs) */
.segmented {
	display: inline-flex;
	margin: 0;
	padding: 3px;
	border: 1px solid var(--border);
	border-radius: 999px;
	background: var(--bg);
	min-width: 0;
}

.segmented input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
	pointer-events: none;
}

.segmented label {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 56px;
	min-height: 38px;
	padding: 0 14px;
	border-radius: 999px;
	font-size: 0.9rem;
	font-weight: 600;
	color: var(--muted);
	cursor: pointer;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
}

.segmented input:checked + label {
	background: var(--accent);
	color: var(--accent-ink);
}

.segmented input:focus-visible + label {
	outline: 2px solid var(--focus);
	outline-offset: 1px;
}

/* Draw card */
.draw {
	background: var(--accent-soft);
	border-color: transparent;
}

.eyebrow {
	margin: 0 0 4px;
	font-size: 0.8rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--accent);
}

.draw-figures {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 4px 14px;
}

output {
	font-variant-numeric: tabular-nums;
}

.big {
	font-size: 2.6rem;
	font-weight: 750;
	line-height: 1.1;
	letter-spacing: -0.02em;
	color: var(--text);
}

.beside {
	font-size: 1.35rem;
	font-weight: 600;
	color: var(--muted);
}

#message {
	margin: 10px 0 0;
	font-size: 0.92rem;
	color: var(--muted);
}

#message:empty {
	display: none;
}

#message[data-kind='warn'] {
	color: var(--warn);
	background: var(--warn-soft);
	padding: 8px 12px;
	border-radius: 10px;
	font-weight: 600;
}

/* Stats */
.stats {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 14px 12px;
}

.stat-wide {
	grid-column: 1 / -1;
	padding-top: 12px;
	border-top: 1px solid var(--border);
}

.stat {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.stat-label {
	font-size: 0.75rem;
	font-weight: 600;
	color: var(--muted);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.stat output {
	font-size: 1.05rem;
	font-weight: 650;
	overflow-wrap: anywhere;
}

.stat-sub {
	font-size: 0.8rem;
	color: var(--muted);
}

.foot {
	text-align: center;
	color: var(--muted);
	font-size: 0.8rem;
}

.foot p {
	margin: 4px 0 0;
}

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

@media (max-width: 360px) {
	.big {
		font-size: 2.2rem;
	}
}
