:root {
	color-scheme: light;
	--desk: #c4beb3;
	--paper: #f1eee6;
	--ink: #2c2924;
	--rule: #b9b3a8;
	--edge: #b7b1a6;
	--shadow: rgba(48, 40, 32, 0.18);
	--focus: #2c2924;
	--font-min: 1rem;
	--font-size: clamp(var(--font-min), 0.92rem + 0.4vw, 1.25rem);
	--desk-pad: clamp(0.35rem, 0.9vw, 0.85rem);
	--side: clamp(1rem, 3.2vw, 2.75rem);
	--side-left: clamp(1.25rem, 3.8vw, 3rem);
	--side-top: clamp(1rem, 3.6vh, 2.4rem);
	--side-bottom: clamp(0.9rem, 3vh, 2rem);
}

:root[data-theme="dark"] {
	color-scheme: dark;
	--desk: #000000;
	--paper: #071446;
	--ink: #f1eee6;
	--rule: #1e4a9c;
	--edge: #0d2a7a;
	--shadow: rgba(0, 16, 64, 0.55);
	--focus: #efc21a;
}

* {
	box-sizing: border-box;
}

html,
body {
	min-height: 100%;
	margin: 0;
	background: var(--desk);
}

html {
	font-size: 100%;
	background: var(--desk);
}

:root[data-theme="dark"],
html[data-theme="dark"] {
	color-scheme: dark;
	background: var(--desk);
}

body {
	background: var(--desk);
	color: var(--ink);
	font-family: Calibri, Carlito, "Segoe UI", "Liberation Sans", Arial, sans-serif;
	font-size: var(--font-size);
	line-height: 1.5;
	font-kerning: normal;
	font-optical-sizing: auto;
	font-variant-ligatures: common-ligatures contextual;
	text-rendering: optimizeLegibility;
}

.skip {
	position: absolute;
	left: 0.75rem;
	top: 0.75rem;
	z-index: 2;
	padding: 0.4em 0.7em;
	background: var(--paper);
	color: var(--ink);
	clip-path: inset(50%);
	white-space: nowrap;
}

.skip:focus {
	clip-path: none;
}

.desk {
	display: grid;
	width: 100%;
	min-height: 100dvh;
	padding: var(--desk-pad);
}

.sheet {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	min-height: calc(100dvh - 2 * var(--desk-pad));
	padding: var(--side-top) var(--side) var(--side-bottom) var(--side-left);
	background: var(--paper);
	box-shadow:
		0 0 0 1px var(--edge),
		0 6px 18px var(--shadow);
}

.letter {
	width: 50%;
	max-width: 100%;
	flex: 1 0 auto;
}

.letter-legal {
	width: min(42rem, 100%);
}

.prose h2 {
	margin: 1.15em 0 0.45em;
	font-size: 1em;
	font-weight: 700;
}

.prose p,
.prose address {
	margin: 0 0 0.8em;
	font-style: normal;
}

.body,
.prose p {
	text-align: justify;
	text-justify: inter-word;
	text-align-last: start;
	-webkit-hyphens: auto;
	hyphens: auto;
	overflow-wrap: break-word;
	text-wrap: pretty;
	hanging-punctuation: first allow-end last;
	hyphenate-limit-chars: 6 2 2;
	hyphenate-limit-lines: 2;
	hyphenate-limit-last: always;
	hyphenate-limit-zone: 4%;
	orphans: 2;
	widows: 2;
}

:lang(en) .body,
:lang(en) .prose p {
	hyphenate-limit-chars: 6 2 3;
}

.prose a {
	-webkit-hyphens: none;
	hyphens: none;
}

.tick {
	position: absolute;
	left: 0;
	width: clamp(0.45rem, 1.1vw, 0.95rem);
	border-top: 1px solid var(--rule);
}

.tick-fold-1 {
	top: 29.29%;
}

.tick-fold-2 {
	top: 64.65%;
}

.tick-hole {
	top: 50%;
	width: 1rem;
}

.head {
	margin: 0 0 1.1rem;
	font-size: 1.05rem;
	letter-spacing: 0.04em;
}

.head a,
.mark-now {
	letter-spacing: 0;
	font-size: 0.95em;
}

.head a {
	text-decoration: underline;
	text-underline-offset: 0.14em;
}

.mark-now {
	opacity: 0.4;
}

.lang {
	position: absolute;
	top: var(--side-top);
	right: var(--side);
	display: flex;
	gap: 0.75em;
	z-index: 1;
	font-size: max(0.875rem, 0.875em);
}

.lang a,
.lang .mark-now {
	padding: 0.35em 0.1em;
}

.theme-toggle {
	appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 0 0.15em 0 0;
	padding: 0.2em;
	border: 0;
	background: none;
	color: inherit;
	cursor: pointer;
	line-height: 0;
}

.theme-toggle svg {
	width: 1.05em;
	height: 1.05em;
	display: block;
}

html:not([data-theme="dark"]) .icon-sun,
html[data-theme="dark"] .icon-moon {
	display: none;
}

.absender {
	margin: 0 0 0.85rem;
	width: min(100%, 18em);
	padding-bottom: 0.2em;
	border-bottom: 1px solid var(--ink);
	font-size: max(0.875rem, 0.875em);
	line-height: 1.3;
}

.meta {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	column-gap: 1.25rem;
	align-items: start;
	margin: 0 0 1.25rem;
}

.anschrift {
	margin: 0;
}

.info {
	margin: 0;
	text-align: right;
	white-space: nowrap;
}

.betreff,
.prose h2 {
	text-wrap: balance;
	-webkit-hyphens: manual;
	hyphens: manual;
}

.betreff {
	margin: 0 0 0.9rem;
	font-size: 1rem;
	font-weight: 700;
	line-height: 1.3;
}

.anrede,
.gruss,
.sign {
	margin: 0 0 0.8rem;
	-webkit-hyphens: none;
	hyphens: none;
}

.body {
	margin: 0 0 0.8rem;
}

.closing {
	margin-top: 1.75rem;
}

.folio {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: baseline;
	column-gap: 1rem;
	width: 100%;
	margin-top: auto;
	padding-top: 1.25rem;
	flex-shrink: 0;
	font-size: max(0.875rem, 0.875em);
}

.folio-meta {
	grid-column: 1;
	display: flex;
	flex-wrap: wrap;
	gap: 0.75em;
	margin: 0;
}

.folio-meta a,
.folio-meta .folio-off {
	padding: 0.35em 0.1em;
}

.folio-page {
	grid-column: 2;
	margin: 0;
	text-align: center;
}

.folio-nav {
	grid-column: 3;
	display: flex;
	justify-content: flex-end;
	gap: 0.75em;
	margin: 0;
	white-space: nowrap;
}

.folio-nav a,
.folio-off {
	padding: 0.35em 0.1em;
}

.folio-off {
	opacity: 0.4;
}

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 0.14em;
}

a:hover {
	text-decoration-thickness: 2px;
}

:focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: 3px;
}

@media (max-width: 48rem) {
	.head {
		padding-right: 8.5rem;
	}

	.letter {
		width: 100%;
	}

	.info {
		white-space: normal;
	}

	.folio {
		grid-template-columns: 1fr;
		justify-items: center;
		row-gap: 0.35rem;
	}

	.folio-meta,
	.folio-page,
	.folio-nav {
		grid-column: 1;
		justify-content: center;
		text-align: center;
	}
}

@media (prefers-contrast: more) {
	:root {
		--desk: #6f6a62;
		--paper: #f7f4ee;
		--ink: #000000;
		--rule: #000000;
		--edge: #000000;
		--focus: #000000;
	}

	html[data-theme="dark"] {
		--desk: #000000;
		--paper: #000000;
		--ink: #ffffff;
		--rule: #ffffff;
		--edge: #ffffff;
		--focus: #efc21a;
	}

	.sheet {
		box-shadow: 0 0 0 2px var(--ink);
	}
}

@media (forced-colors: active) {
	.sheet {
		border: 1px solid CanvasText;
		box-shadow: none;
	}

	.absender,
	.colophon,
	.tick {
		border-color: CanvasText;
	}

	:focus-visible {
		outline-color: Highlight;
	}
}

@media (prefers-reduced-motion: reduce) {
	* {
		scroll-behavior: auto;
	}
}

@media print {
	body {
		background: white;
	}

	.skip,
	.lang {
		display: none;
	}

	.desk {
		display: block;
		height: auto;
		min-height: 0;
		padding: 0;
	}

	.sheet {
		width: 210mm;
		height: 297mm;
		overflow: hidden;
		box-shadow: none;
		padding: 20mm 20mm 20mm 25mm;
	}

	body {
		font-size: 11pt;
	}

	.letter {
		width: 100%;
	}

	@page {
		size: A4;
		margin: 0;
	}
}
