@font-face {
	font-family: "Newsreader";
	src: url("fonts/newsreader-latin.woff2") format("woff2");
	font-weight: 300 600;
	font-display: swap;
}

:root {
	--paper: #F2F4F6;
	--sheet: #FFFFFF;
	--ink: #1A2230;
	--muted: #5B6573;
	--rule: #D3D9E0;
	--pencil: #2350D8;
	--pencil-ink: #FFFFFF;
	--highlight: #CFE6F2;
	--warn: #B3261E;

	--serif: "Newsreader", "Iowan Old Style", Georgia, serif;
	--sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

	/* Type scale: 1.25 ratio off a 17px body. */
	--t-sm: 0.8125rem;
	--t-ui: 0.9375rem;
	--t-body: 1.0625rem;
	--t-lede: 1.3125rem;
	--t-h2: 1.375rem;
	--t-h1: clamp(2.25rem, 1.2rem + 4.2vw, 4.25rem);

	--gutter: 24px;
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root {
		--paper: #121926;
		--sheet: #182131;
		--ink: #E6EAF0;
		--muted: #9AA5B4;
		--rule: #2C384B;
		--pencil: #7FA4FF;
		--pencil-ink: #0E1522;
		--highlight: #1F3350;
		--warn: #FF8A80;
		color-scheme: dark;
	}
}

* { box-sizing: border-box; }

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

body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font: 400 var(--t-body)/1.6 var(--sans);
	-webkit-font-smoothing: antialiased;
}

.top, main, .foot {
	max-width: 1180px;
	margin: 0 auto;
	padding-left: var(--gutter);
	padding-right: var(--gutter);
}

/* Header */
.top {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	padding-top: 22px;
}

.brand {
	font: 500 1.5rem/1 var(--serif);
	color: var(--ink);
	text-decoration: none;
	letter-spacing: -0.01em;
}

.quota { font-size: var(--t-sm); color: var(--muted); }

/* Hero: the headline is itself an edit */
.hero { padding: clamp(40px, 7vw, 88px) 0 clamp(28px, 4vw, 44px); }

.edit {
	font: 400 var(--t-h1)/1.06 var(--serif);
	font-optical-sizing: auto;
	letter-spacing: -0.02em;
	margin: 0;
	max-width: 15ch;
}

/* Inline + cloned background so every wrapped line gets its own pencil strike. */
.edit .struck {
	color: var(--muted);
	font-weight: 300;
	background-image: linear-gradient(var(--pencil), var(--pencil));
	background-repeat: no-repeat;
	background-position: 0 60%;
	background-size: 100% 0.08em;
	-webkit-box-decoration-break: clone;
	box-decoration-break: clone;
	animation: strike 900ms cubic-bezier(0.6, 0, 0.2, 1) 350ms both;
}

.edit .kept { display: block; margin-top: 0.08em; }

@keyframes strike { from { background-size: 0% 0.08em; } }

@media (prefers-reduced-motion: reduce) {
	.edit .struck { animation: none; }
}

.lede {
	margin: 22px 0 0;
	max-width: 34em;
	font: 400 var(--t-lede)/1.5 var(--serif);
	color: var(--muted);
	text-wrap: pretty;
}

/* The desk: draft and clean copy side by side */
.desk {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 20px;
}

.sheet {
	display: flex;
	flex-direction: column;
	background: var(--sheet);
	border: 1px solid var(--rule);
	border-radius: 4px;
	min-height: 420px;
}
.sheet:focus-within { border-color: var(--pencil); }

.sheet-out { border-style: dashed; }
.sheet-out.has-copy { border-style: solid; }

.sheet-head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	min-height: 46px;
	padding: 8px 18px;
	border-bottom: 1px solid var(--rule);
	font-size: var(--t-ui);
	font-weight: 600;
}

.count {
	font-size: var(--t-sm);
	font-weight: 400;
	color: var(--muted);
	font-variant-numeric: tabular-nums;
}
.count.over { color: var(--warn); font-weight: 600; }

textarea, .output {
	flex: 1;
	width: 100%;
	max-height: 62vh;
	overflow-y: auto;
	padding: 16px 18px 20px;
	border: 0;
	background: transparent;
	color: var(--ink);
	font: 400 1.125rem/1.7 var(--serif);
	resize: none;
}
textarea:focus, .output:focus { outline: none; }
textarea::placeholder { color: var(--muted); opacity: 1; }

.output { white-space: pre-wrap; overflow-wrap: anywhere; }
.output.loading { color: var(--muted); }
.placeholder { margin: 0; color: var(--muted); }

/* Controls */
.controls {
	grid-column: 1 / -1;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 14px 26px;
	font-size: var(--t-ui);
}

.field { display: flex; align-items: center; gap: 10px; }

select {
	font: inherit;
	color: var(--ink);
	background: var(--sheet);
	border: 1px solid var(--rule);
	border-radius: 4px;
	padding: 8px 10px;
}

.check { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--pencil); }

button { font: 600 var(--t-ui) var(--sans); cursor: pointer; }
button:disabled { cursor: not-allowed; }

.clean {
	margin-left: auto;
	padding: 13px 30px;
	border: 0;
	border-radius: 4px;
	background: var(--pencil);
	color: var(--pencil-ink);
	font-size: 1rem;
}
.clean:not(:disabled):hover { filter: brightness(1.1); }
.clean:disabled { background: var(--rule); color: var(--muted); }

.copy {
	padding: 5px 12px;
	border: 1px solid var(--rule);
	border-radius: 4px;
	background: transparent;
	color: var(--ink);
	font-size: var(--t-sm);
}
.copy:not(:disabled):hover { border-color: var(--pencil); color: var(--pencil); }
.copy:disabled { color: var(--muted); opacity: 0.6; }

:focus-visible { outline: 2px solid var(--pencil); outline-offset: 2px; }
textarea:focus-visible, .output:focus-visible { outline: none; }

.status {
	grid-column: 1 / -1;
	margin: 0;
	min-height: 1.6em;
	font-size: var(--t-ui);
	color: var(--muted);
}
.status.error { color: var(--warn); }

/* What gets cut */
.cuts {
	margin-top: clamp(40px, 6vw, 64px);
	padding-top: 28px;
	border-top: 1px solid var(--rule);
}

.cuts h2, .fine strong { font-family: var(--serif); }

.cuts h2 {
	margin: 0 0 18px;
	font-size: var(--t-h2);
	font-weight: 500;
}

.cut-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 10px 30px;
	font: 400 1.25rem/1.4 var(--serif);
	color: var(--muted);
}

.cut-list s {
	text-decoration: line-through;
	text-decoration-color: var(--pencil);
	text-decoration-thickness: 2px;
}

.cuts-note {
	max-width: 40em;
	margin: 22px 0 0;
	color: var(--ink);
}

.fine {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 18px 48px;
	margin-top: 48px;
	padding: 22px 0;
	border-top: 1px solid var(--rule);
	font-size: var(--t-ui);
	color: var(--muted);
}
.fine p { margin: 0; max-width: 36em; }
.fine strong { color: var(--ink); font-weight: 600; font-size: 1.0625rem; }

.foot {
	padding-top: 24px;
	padding-bottom: 40px;
	font-size: var(--t-sm);
	color: var(--muted);
}

/* Phone */
@media (max-width: 760px) {
	:root { --gutter: 16px; }
	.top { padding-top: 16px; }
	.desk { grid-template-columns: 1fr; gap: 14px; }
	.sheet { min-height: 240px; }
	textarea, .output { max-height: 48vh; }
	.controls { gap: 12px 20px; }
	.clean { margin-left: 0; width: 100%; }
	.cut-list { font-size: 1.0625rem; gap: 8px 20px; }
	.fine { grid-template-columns: 1fr; }
}
