:root {
	--paper: #f6f3ec;
	--surface: #fffdf8;
	--surface-strong: #ffffff;
	--ink: #23251f;
	--muted: #6e7168;
	--line: #d8d2c2;
	--field: #fbfaf5;
	--focus: #2f6f58;
	--amber: #b56a1d;
	--danger: #9f2f29;
	--shadow: 0 14px 40px rgba(41, 39, 30, 0.10);
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	min-height: 100vh;
	background:
		linear-gradient(90deg, rgba(47, 111, 88, 0.05) 1px, transparent 1px),
		linear-gradient(0deg, rgba(47, 111, 88, 0.05) 1px, transparent 1px),
		var(--paper);
	background-size: 48px 48px;
	color: var(--ink);
	font-family: "Segoe UI", Arial, sans-serif;
	font-size: 15px;
	letter-spacing: 0;
}

button,
input,
textarea {
	font: inherit;
	letter-spacing: 0;
}

.shell {
	width: min(1440px, 100%);
	margin: 0 auto;
	padding: 22px;
}

.topbar {
	display: flex;
	align-items: end;
	justify-content: space-between;
	gap: 18px;
	padding: 4px 2px 18px;
}

h1 {
	margin: 0;
	font-size: 30px;
	line-height: 1;
	font-weight: 700;
}

.dateline {
	margin: 7px 0 0;
	color: var(--muted);
}

.status-pill {
	border: 1px solid var(--line);
	background: rgba(255, 253, 248, 0.82);
	border-radius: 999px;
	padding: 7px 11px;
	color: var(--muted);
	font-size: 13px;
	white-space: nowrap;
}

.workspace {
	display: grid;
	grid-template-columns: minmax(280px, 360px) minmax(0, 1fr) minmax(140px, 190px);
	gap: 16px;
	align-items: stretch;
	min-height: calc(100vh - 104px);
}

.panel {
	background: var(--surface);
	border: 1px solid var(--line);
	box-shadow: var(--shadow);
	border-radius: 8px;
	padding: 14px;
}

.input-panel {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.output-panel {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.field-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 10px;
	min-height: 24px;
}

label {
	font-weight: 700;
}

fieldset {
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.hint {
	color: var(--muted);
	font-size: 12px;
	text-align: right;
}

textarea {
	width: 100%;
	min-height: 192px;
	resize: vertical;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--field);
	color: var(--ink);
	padding: 11px;
	font-family: Consolas, "Cascadia Mono", monospace;
	line-height: 1.45;
	text-transform: uppercase;
	outline: none;
}

textarea.compact {
	min-height: 104px;
}

input:focus,
textarea:focus,
pre:focus {
	border-color: var(--focus);
	box-shadow: 0 0 0 3px rgba(47, 111, 88, 0.15);
}

.layout-settings {
	display: flex;
	flex-direction: column;
	gap: 10px;
	border-top: 1px solid var(--line);
	padding-top: 12px;
}

.layout-settings legend {
	padding: 0 0 8px;
	font-weight: 700;
}

.segmented {
	display: grid;
	grid-template-columns: 1fr 1fr;
	border: 1px solid var(--line);
	border-radius: 6px;
	overflow: hidden;
	background: var(--field);
}

.segmented label {
	position: relative;
	min-width: 0;
	font-weight: 600;
	text-align: center;
}

.segmented label + label {
	border-left: 1px solid var(--line);
}

.segmented input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.segmented span {
	display: block;
	padding: 8px 6px;
}

.segmented input:checked + span {
	background: var(--focus);
	color: white;
}

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

.number-grid label {
	display: grid;
	gap: 4px;
	min-width: 0;
	color: var(--muted);
	font-size: 12px;
}

.number-grid input {
	width: 100%;
	height: 34px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--field);
	color: var(--ink);
	padding: 6px 8px;
	outline: none;
}

.check-row {
	display: flex;
	align-items: center;
	gap: 8px;
	color: var(--ink);
	font-weight: 700;
}

.check-row input {
	width: 16px;
	height: 16px;
	accent-color: var(--focus);
}

.cutout-grid[aria-disabled="true"] {
	opacity: 0.55;
}

.actions {
	display: grid;
	grid-template-columns: 1fr 1fr 1fr;
	gap: 8px;
}

button {
	height: 38px;
	border: 1px solid #bfb8a7;
	border-radius: 6px;
	background: var(--surface-strong);
	color: var(--ink);
	cursor: pointer;
}

button:hover:not(:disabled) {
	border-color: #88806f;
	background: #f7f4ec;
}

button.primary {
	background: var(--focus);
	border-color: var(--focus);
	color: white;
	font-weight: 700;
}

button:disabled {
	cursor: not-allowed;
	color: #9a9a91;
	background: #efede7;
}

.message {
	min-height: 22px;
	color: var(--muted);
	font-size: 13px;
	line-height: 1.35;
}

.message.error {
	color: var(--danger);
}

pre {
	flex: 1;
	min-height: 480px;
	margin: 8px 0 0;
	overflow: auto;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: #fffefa;
	padding: 14px;
	color: #1f211d;
	font-family: Consolas, "Cascadia Mono", monospace;
	font-size: 13px;
	line-height: 1.35;
	white-space: pre;
	tab-size: 8;
	outline: none;
}

.ansi-bold {
	font-weight: 700;
}

.ansi-italic {
	font-style: italic;
}

.ansi-underline {
	text-decoration-line: underline;
	text-decoration-thickness: from-font;
	text-underline-offset: auto;
}

.ad-rail {
	border: 1px dashed rgba(110, 113, 104, 0.35);
	border-radius: 8px;
	min-height: 180px;
	background: rgba(255, 253, 248, 0.45);
}

@media (max-width: 980px) {
	.shell {
		padding: 14px;
	}

	.topbar {
		align-items: start;
	}

	.workspace {
		grid-template-columns: 1fr;
		min-height: auto;
	}

	.ad-rail {
		min-height: 72px;
	}

	pre {
		min-height: 420px;
	}
}

@media (max-width: 560px) {
	.topbar {
		flex-direction: column;
	}

	.actions {
		grid-template-columns: 1fr;
	}
}
