:root {
	--background: #f4f5f7;
	--surface: #ffffff;
	--surface-hover: #eceef2;
	--border: #d7dbe2;
	--text: #101418;
	--text-muted: #5c6673;
	--accent: #1d63d8;
	--accent-text: #ffffff;
	color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
	:root {
		--background: #101418;
		--surface: #191f26;
		--surface-hover: #222a33;
		--border: #2c343e;
		--text: #f2f4f7;
		--text-muted: #9aa5b2;
		--accent: #4d8dff;
		--accent-text: #06101f;
	}
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	padding: 0;
}

body {
	min-height: 100dvh;
	background: var(--background);
	color: var(--text);
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	font-size: 17px;
	line-height: 1.4;
	-webkit-text-size-adjust: 100%;
}

.app {
	display: flex;
	flex-direction: column;
	gap: 1.5rem;
	max-width: 40rem;
	margin: 0 auto;
	padding: 1rem;
	padding-top: max(1rem, env(safe-area-inset-top));
	padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

.composer {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.composer-input {
	width: 100%;
	padding: 0.875rem 1rem;
	border: 1px solid var(--border);
	border-radius: 0.875rem;
	background: var(--surface);
	color: inherit;
	font: inherit;
	font-size: 1.125rem;
	resize: vertical;
}

.composer-input:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 1px;
}

.composer-submit {
	min-height: 3.25rem;
	border: 0;
	border-radius: 0.875rem;
	background: var(--accent);
	color: var(--accent-text);
	font: inherit;
	font-size: 1.125rem;
	font-weight: 600;
	cursor: pointer;
	touch-action: manipulation;
}

.composer-submit:active {
	opacity: 0.8;
}

.status {
	min-height: 1.4em;
	margin: 0;
	color: var(--text-muted);
	font-size: 0.9375rem;
}

.status[data-tone="error"] {
	color: #d2453c;
}

@media (prefers-color-scheme: dark) {
	.status[data-tone="error"] {
		color: #ff8279;
	}
}

.history {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.history-header {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
}

.history-heading {
	margin: 0;
	color: var(--text-muted);
	font-size: 0.8125rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.history-clear {
	padding: 0.25rem 0;
	border: 0;
	background: none;
	color: var(--text-muted);
	font: inherit;
	font-size: 0.9375rem;
	cursor: pointer;
	touch-action: manipulation;
}

.history-empty {
	margin: 0;
	color: var(--text-muted);
	font-size: 0.9375rem;
}

.history-list {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.history-item {
	display: flex;
	align-items: stretch;
	gap: 0.25rem;
	border: 1px solid var(--border);
	border-radius: 0.875rem;
	background: var(--surface);
	overflow: hidden;
}

.history-play,
.history-pin {
	min-height: 3rem;
	padding: 0.75rem 1rem;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	cursor: pointer;
	touch-action: manipulation;
}

.history-play {
	flex: 1;
	text-align: left;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.history-pin {
	flex: none;
	padding-inline: 0.875rem;
	color: var(--text-muted);
	font-size: 1.375rem;
	line-height: 1;
}

.history-pin[aria-pressed="true"] {
	color: #eab308;
}

.history-play:active,
.history-pin:active {
	background: var(--surface-hover);
}

.history-lang {
	display: inline-block;
	margin-inline-end: 0.5rem;
	padding: 0.0625rem 0.375rem;
	border-radius: 0.375rem;
	background: var(--surface-hover);
	color: var(--text-muted);
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	vertical-align: 0.05em;
}

.settings {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.settings-heading {
	margin: 0;
	color: var(--text-muted);
	font-size: 0.8125rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.settings-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	min-height: 3.25rem;
	padding: 0.5rem 1rem;
	border: 1px solid var(--border);
	border-radius: 0.875rem;
	background: var(--surface);
}

.settings-text {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 0.125rem;
	min-width: 0;
}

.settings-note {
	color: var(--text-muted);
	font-size: 0.875rem;
}

.settings-checkbox {
	flex: none;
	width: 1.5rem;
	height: 1.5rem;
	margin: 0;
	accent-color: var(--accent);
	cursor: pointer;
	touch-action: manipulation;
}

.settings-footer {
	margin: 0;
	font-size: 0.9375rem;
}

.settings-link {
	color: var(--text-muted);
}

.settings-select {
	flex: 0 1 auto;
	max-width: 60%;
	padding: 0.5rem 0.5rem;
	border: 1px solid var(--border);
	border-radius: 0.625rem;
	background: var(--background);
	color: inherit;
	font: inherit;
	touch-action: manipulation;
}

.composer-actions {
	display: flex;
	gap: 0.5rem;
}

.composer-submit {
	flex: 2;
}

.composer-show {
	flex: 1;
	min-height: 3.25rem;
	border: 1px solid var(--border);
	border-radius: 0.875rem;
	background: var(--surface);
	color: inherit;
	font: inherit;
	font-size: 1.125rem;
	font-weight: 600;
	cursor: pointer;
	touch-action: manipulation;
}

.composer-show:active {
	background: var(--surface-hover);
}

.history-show {
	flex: none;
	min-height: 3rem;
	padding: 0.75rem 0.75rem;
	border: 0;
	background: none;
	color: var(--text-muted);
	cursor: pointer;
	touch-action: manipulation;
}

.history-show svg {
	display: block;
	width: 1.375rem;
	height: 1.375rem;
}

.history-show:active {
	background: var(--surface-hover);
}

/* Must come with the display rule below: an author `display` beats the
   browser's `[hidden] { display: none }`, which left the overlay covering the
   page and swallowing every tap. */
.overlay[hidden] {
	display: none;
}

.overlay {
	position: fixed;
	inset: 0;
	z-index: 10;
	display: flex;
	flex-direction: column;
	gap: 1rem;
	padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
	background: var(--surface);
}

.overlay-text {
	display: flex;
	flex: 1;
	align-items: center;
	justify-content: center;
	margin: 0;
	overflow-y: auto;
	font-weight: 700;
	line-height: 1.15;
	text-align: center;
	overflow-wrap: anywhere;
	hyphens: auto;
}

/* Short phrases are the ones read across a room, so they get the most size. */
.overlay[data-size='xl'] .overlay-text {
	font-size: min(22vw, 20vh);
}

.overlay[data-size='l'] .overlay-text {
	font-size: min(13vw, 12vh);
}

.overlay[data-size='m'] .overlay-text {
	font-size: min(8vw, 8vh);
}

.overlay[data-size='s'] .overlay-text {
	font-size: min(5.5vw, 5vh);
}

.overlay-actions {
	display: flex;
	flex: none;
	gap: 0.5rem;
}

.overlay-speak,
.overlay-close {
	flex: 1;
	min-height: 3.25rem;
	border: 1px solid var(--border);
	border-radius: 0.875rem;
	background: var(--background);
	color: inherit;
	font: inherit;
	font-size: 1.125rem;
	font-weight: 600;
	cursor: pointer;
	touch-action: manipulation;
}

.overlay-speak {
	border-color: transparent;
	background: var(--accent);
	color: var(--accent-text);
}

.overlay-speak:active,
.overlay-close:active {
	opacity: 0.8;
}

/* privacy.html */
.page {
	max-width: 40rem;
	margin: 0 auto;
	padding: 1rem;
	padding-top: max(1rem, env(safe-area-inset-top));
	padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

.page-nav {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	margin-bottom: 1.5rem;
	font-size: 0.9375rem;
}

.page-back {
	margin-inline-end: auto;
}

.page a {
	color: var(--accent);
}

.page h1 {
	margin: 0 0 1rem;
	font-size: 1.75rem;
	line-height: 1.2;
}

.page h2 {
	margin: 1.5rem 0 0.5rem;
	font-size: 1.125rem;
}

.page p,
.page ul {
	margin: 0 0 0.75rem;
}

.page ul {
	padding-inline-start: 1.25rem;
}

.page li + li {
	margin-top: 0.5rem;
}

.page-updated {
	color: var(--text-muted);
	font-size: 0.9375rem;
}

/* One language at a time once the hash names it; every browser without
   :has() simply shows all three. */
.page:has(section:target) section:not(:target) {
	display: none;
}
