.tvt-app {
	--tvt-ink: #171715;
	--tvt-muted: #686862;
	--tvt-paper: #f3f0e8;
	--tvt-panel: #fff;
	--tvt-line: #d9d5ca;
	--tvt-accent: #b75432;
	--tvt-accent-dark: #85391f;
	--tvt-success: #34624a;
	--tvt-error: #a12c2c;
	color: var(--tvt-ink);
	font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	margin: 2rem auto;
	max-width: 1440px;
}

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

.tvt-app [hidden] {
	display: none !important;
}

.tvt-heading {
	border-bottom: 1px solid var(--tvt-line);
	margin-bottom: 1.5rem;
	padding-bottom: 1.5rem;
}

.tvt-heading h2 {
	font-family: Georgia, "Times New Roman", serif;
	font-size: clamp(2rem, 5vw, 4.5rem);
	font-weight: 400;
	letter-spacing: -0.045em;
	line-height: 0.98;
	margin: 0.2rem 0 0.75rem;
}

.tvt-heading > p:last-child {
	color: var(--tvt-muted);
	font-size: 1.05rem;
	margin: 0;
	max-width: 680px;
}

.tvt-eyebrow {
	color: var(--tvt-accent);
	font-size: 0.72rem;
	font-weight: 750;
	letter-spacing: 0.15em;
	margin: 0;
	text-transform: uppercase;
}

.tvt-upload {
	background:
		linear-gradient(rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.86)),
		repeating-linear-gradient(45deg, #ebe7dc 0, #ebe7dc 1px, transparent 1px, transparent 12px);
	border: 1px solid var(--tvt-line);
	padding: clamp(1rem, 4vw, 3rem);
}

.tvt-upload__form {
	margin: 0;
}

.tvt-dropzone {
	align-items: center;
	border: 1.5px dashed #9e998d;
	cursor: pointer;
	display: flex;
	flex-direction: column;
	justify-content: center;
	min-height: 330px;
	padding: 2rem;
	text-align: center;
	transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.tvt-dropzone:hover,
.tvt-dropzone:focus-within,
.tvt-dropzone.is-dragging {
	background: #fff;
	border-color: var(--tvt-accent);
	transform: translateY(-2px);
}

.tvt-dropzone input {
	height: 1px;
	opacity: 0;
	overflow: hidden;
	position: absolute;
	width: 1px;
}

.tvt-dropzone__mark {
	align-items: center;
	background: var(--tvt-ink);
	border-radius: 50%;
	color: #fff;
	display: flex;
	font-family: Georgia, serif;
	font-size: 2rem;
	height: 58px;
	justify-content: center;
	line-height: 1;
	margin-bottom: 1.2rem;
	width: 58px;
}

.tvt-dropzone__title {
	font-family: Georgia, "Times New Roman", serif;
	font-size: clamp(1.55rem, 3vw, 2.4rem);
}

.tvt-dropzone__help,
.tvt-privacy,
.tvt-upload-status {
	color: var(--tvt-muted);
	font-size: 0.85rem;
}

.tvt-dropzone__help {
	margin-top: 0.55rem;
}

.tvt-privacy {
	margin: 0.9rem 0 0;
	text-align: center;
}

.tvt-upload-status {
	margin: 0.6rem 0 0;
	min-height: 1.3rem;
	text-align: center;
}

.tvt-upload-status--working {
	animation: tvt-pulse 1.2s ease-in-out infinite;
	color: var(--tvt-accent-dark);
}

.tvt-upload-status--error {
	color: var(--tvt-error);
}

.tvt-workspace {
	align-items: start;
	display: grid;
	gap: 1.5rem;
	grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
}

.tvt-controls {
	background: var(--tvt-paper);
	border: 1px solid var(--tvt-line);
	padding: 1.25rem;
	position: sticky;
	top: 1rem;
}

.tvt-controls__header,
.tvt-preview-card__header,
.tvt-field__label {
	align-items: center;
	display: flex;
	justify-content: space-between;
}

.tvt-controls__header {
	border-bottom: 1px solid var(--tvt-line);
	margin-bottom: 1.1rem;
	padding-bottom: 1rem;
}

.tvt-controls h3,
.tvt-preview-card h3 {
	font-family: Georgia, "Times New Roman", serif;
	font-weight: 400;
	margin: 0;
}

.tvt-controls h3 {
	font-size: 1.45rem;
}

.tvt-text-button,
.tvt-download {
	background: transparent;
	border: 0;
	color: var(--tvt-accent-dark);
	cursor: pointer;
	font-size: 0.76rem;
	font-weight: 750;
	letter-spacing: 0.06em;
	padding: 0;
	text-decoration: underline;
	text-underline-offset: 3px;
	text-transform: uppercase;
}

.tvt-field {
	border-bottom: 1px solid rgba(91, 87, 78, 0.15);
	margin-bottom: 1rem;
	padding-bottom: 1rem;
}

.tvt-field label {
	font-size: 0.88rem;
	font-weight: 700;
}

.tvt-field output {
	color: var(--tvt-accent-dark);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.78rem;
}

.tvt-field > p,
.tvt-advanced > p {
	color: var(--tvt-muted);
	font-size: 0.75rem;
	line-height: 1.4;
	margin: 0.4rem 0 0;
}

.tvt-field input[type="range"] {
	accent-color: var(--tvt-accent);
	cursor: pointer;
	margin: 0.6rem 0 0;
	width: 100%;
}

.tvt-field--select select {
	background: #fff;
	border: 1px solid #bbb5a8;
	border-radius: 0;
	color: var(--tvt-ink);
	display: block;
	font: inherit;
	margin-top: 0.55rem;
	padding: 0.65rem 0.7rem;
	width: 100%;
}

.tvt-check {
	align-items: flex-start;
	cursor: pointer;
	display: flex;
	font-size: 0.82rem;
	gap: 0.55rem;
	line-height: 1.4;
	margin: 1rem 0;
}

.tvt-check input {
	accent-color: var(--tvt-accent);
	margin-top: 0.2rem;
}

.tvt-advanced {
	border-bottom: 1px solid var(--tvt-line);
	border-top: 1px solid var(--tvt-line);
	margin: 1.2rem 0;
	padding: 0.85rem 0;
}

.tvt-advanced summary {
	cursor: pointer;
	font-size: 0.83rem;
	font-weight: 750;
}

.tvt-advanced[open] summary {
	margin-bottom: 0.75rem;
}

.tvt-boundary-scale {
	color: var(--tvt-muted);
	display: flex;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.65rem;
	justify-content: space-between;
	margin: 0.7rem 0;
}

.tvt-field--compact {
	margin-bottom: 0.6rem;
	padding-bottom: 0.6rem;
}

.tvt-field--compact label {
	font-size: 0.73rem;
}

.tvt-primary-button,
.tvt-secondary-button {
	border-radius: 0;
	cursor: pointer;
	font-size: 0.78rem;
	font-weight: 800;
	letter-spacing: 0.08em;
	min-height: 48px;
	padding: 0.8rem 1rem;
	text-transform: uppercase;
	width: 100%;
}

.tvt-primary-button {
	background: var(--tvt-ink);
	border: 1px solid var(--tvt-ink);
	color: #fff;
}

.tvt-primary-button:hover {
	background: var(--tvt-accent-dark);
	border-color: var(--tvt-accent-dark);
}

.tvt-secondary-button {
	background: transparent;
	border: 1px solid #aaa397;
	color: var(--tvt-ink);
	margin-top: 0.6rem;
}

.tvt-app.is-busy button,
.tvt-app.is-busy input,
.tvt-app.is-busy select {
	cursor: wait;
	opacity: 0.58;
}

.tvt-results {
	min-width: 0;
}

.tvt-status {
	border-left: 3px solid transparent;
	color: var(--tvt-muted);
	font-size: 0.88rem;
	margin-bottom: 1rem;
	min-height: 1.4rem;
	padding: 0.25rem 0.7rem;
}

.tvt-status--working {
	animation: tvt-pulse 1.2s ease-in-out infinite;
	border-color: var(--tvt-accent);
}

.tvt-status--success {
	border-color: var(--tvt-success);
	color: var(--tvt-success);
}

.tvt-status--error {
	border-color: var(--tvt-error);
	color: var(--tvt-error);
}

.tvt-preview-grid {
	display: grid;
	gap: 1.2rem;
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tvt-preview-card {
	background: var(--tvt-panel);
	border: 1px solid var(--tvt-line);
	min-width: 0;
	padding: 1rem;
}

.tvt-preview-card--wide {
	grid-column: 1 / -1;
}

.tvt-preview-card__header {
	margin-bottom: 0.8rem;
}

.tvt-preview-card__header > div {
	align-items: baseline;
	display: flex;
	gap: 0.65rem;
}

.tvt-preview-card__header span {
	color: var(--tvt-accent);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.7rem;
}

.tvt-preview-card h3 {
	font-size: 1.35rem;
}

.tvt-canvas {
	align-items: center;
	background:
		linear-gradient(45deg, #f4f2ec 25%, transparent 25%),
		linear-gradient(-45deg, #f4f2ec 25%, transparent 25%),
		linear-gradient(45deg, transparent 75%, #f4f2ec 75%),
		linear-gradient(-45deg, transparent 75%, #f4f2ec 75%),
		#fff;
	background-position: 0 0, 0 8px, 8px -8px, -8px 0;
	background-size: 16px 16px;
	border: 1px solid #e2ded5;
	display: flex;
	justify-content: center;
	min-height: 310px;
	overflow: auto;
	position: relative;
}

.tvt-canvas--trace {
	background: #fff;
	min-height: 440px;
}

.tvt-canvas img {
	display: block;
	height: auto;
	max-height: 70vh;
	max-width: 100%;
	object-fit: contain;
}

.tvt-canvas--empty img,
.tvt-canvas:not(.tvt-canvas--empty) > span {
	display: none;
}

.tvt-canvas--empty > span {
	color: var(--tvt-muted);
	font-size: 0.82rem;
	padding: 2rem;
	text-align: center;
}

.tvt-value-key {
	display: grid;
	grid-template-columns: repeat(6, 1fr);
	margin-top: 0.75rem;
}

.tvt-value-key > span {
	align-items: center;
	display: flex;
	font-size: 0.63rem;
	gap: 0.3rem;
	white-space: nowrap;
}

.tvt-value-key > span::before {
	background: var(--tone);
	border: 1px solid #aaa;
	content: "";
	display: block;
	height: 11px;
	width: 11px;
}

.tvt-value-key small {
	color: var(--tvt-muted);
	font-size: 0.58rem;
	font-weight: 700;
	margin-left: 0.15rem;
}

.tvt-alert {
	border-left: 4px solid currentColor;
	margin: 1.5rem 0;
	padding: 1rem;
}

.tvt-alert--error {
	color: var(--tvt-error);
}

@keyframes tvt-pulse {
	50% {
		opacity: 0.55;
	}
}

@media (max-width: 980px) {
	.tvt-workspace {
		grid-template-columns: 1fr;
	}

	.tvt-controls {
		position: static;
	}
}

@media (max-width: 680px) {
	.tvt-preview-grid {
		grid-template-columns: 1fr;
	}

	.tvt-preview-card--wide {
		grid-column: auto;
	}

	.tvt-value-key {
		gap: 0.35rem;
		grid-template-columns: repeat(3, 1fr);
	}

	.tvt-canvas,
	.tvt-canvas--trace {
		min-height: 260px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tvt-app *,
	.tvt-app *::before,
	.tvt-app *::after {
		animation-duration: 0.01ms !important;
		scroll-behavior: auto !important;
		transition-duration: 0.01ms !important;
	}
}
