:root {
	/* Palette matched to the ARI/File Format Studio logo: deep navy + cyan-blue accent + brand green. */
	--bg: #08192a;
	--surface: #102636;
	--surface-2: #163243;
	--border: #2a4d64;
	--text: #e6f2f8;
	--muted: #93b1c2;
	--accent: #17c8f5;
	--accent-2: #56d9ff;
	--accent-soft: rgba(23, 200, 245, 0.13);
	--danger: #ff6b6b;
	--ok: #86e51f;
	--radius: 14px;
	--maxw: 720px;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
	background: radial-gradient(1200px 600px at 50% -10%, #14344a 0%, var(--bg) 55%);
	color: var(--text);
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	/* Vertically centered. The swappable source panels share a fixed min-height (below), so switching
	   source no longer changes the height and the UI doesn't jump while re-centering. */
	justify-content: center;
	line-height: 1.5;
}

/* Full-screen background video (fixed behind all content). */
.bg-video {
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	z-index: -2;
	pointer-events: none;
}
/* Subtle scrim over the video so the UI stays legible. */
body::before {
	content: "";
	position: fixed;
	inset: 0;
	z-index: -1;
	pointer-events: none;
	background: linear-gradient(180deg, rgba(8,25,42,.55) 0%, rgba(8,25,42,.22) 26%, rgba(8,25,42,.22) 70%, rgba(8,25,42,.6) 100%);
}

/* Header */
.site-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 18px 24px 4px;
	max-width: var(--maxw);
	width: 100%;
	margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); width: 100%; }
.brand-mark { font-size: 22px; color: var(--accent); }
/* Animated inline logo (version D), viewBox 1164×220. Scales to the header width, capped. */
.brand-logo {
	width: 100%;
	max-width: 480px;
	height: auto;
	display: block;
}
.brand-name { font-weight: 650; letter-spacing: 0.2px; }
.pill {
	font-size: 13px;
	color: var(--accent);
	background: var(--accent-soft);
	border: 1px solid var(--border);
	padding: 5px 12px;
	border-radius: 999px;
}

/* Layout */
.wrap {
	width: 100%;
	max-width: var(--maxw);
	margin: 0 auto;
	padding: 8px 24px 64px;
}

.hero { text-align: center; margin: 24px 0 32px; }
.lede { color: var(--muted); margin: 0 auto; max-width: 48ch; }
code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-size: 0.9em; }

/* Converter card */
.converter {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 22px;
	display: flex;
	flex-direction: column;
	gap: 18px;
}

/* Dropzone */
/* File source tabs (This device / Web link / Google Drive / …) — laid out as an even grid so every
   button is the same width and the rows stay tidy at any screen size. */
.source-tabs {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 8px;
	margin-bottom: 14px;
}
.source-tab {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 9px 12px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface-2);
	color: var(--muted);
	font-size: 14px;
	line-height: 1.2;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	cursor: pointer;
	transition: border-color .15s, color .15s, background .15s;
}
.source-tab:hover { color: var(--text); border-color: var(--accent); }
.source-tab.is-active {
	color: var(--accent);
	border-color: var(--accent);
	background: var(--accent-soft);
}
.source-ic { font-size: 13px; }
/* Narrow screens: 2 even columns instead of 3 so labels never get cramped. */
@media (max-width: 560px) {
	.source-tabs { grid-template-columns: repeat(2, 1fr); }
}
/* All swappable source panels (dropzone + cloud/URL) share this height so switching source doesn't
   change the layout height — the UI stays centered without jumping. Content is centered within. */
.dropzone, .cloud-panel {
	min-height: 188px;
	display: flex;
	flex-direction: column;
	justify-content: center;
}
.cloud-panel {
	border: 2px dashed var(--border);
	border-radius: var(--radius);
	background: var(--surface-2);
	padding: 32px 20px;
	text-align: center;
}
.btn-cloud { font-size: 15px; background: var(--accent); color: #0b0d12; }
.btn-cloud:hover { background: var(--accent-2); }
.cloud-hint { margin: 12px 0 0; color: var(--muted); font-size: 14px; }
/* Web-link (URL) source */
.url-row { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; justify-content: center; }
.url-input {
	flex: none;
	align-self: center;
	width: 100%;
	max-width: 420px;
	background: var(--surface);
	border: 1px solid var(--border);
	color: var(--text);
	border-radius: var(--radius);
	padding: 10px 14px;
	font: inherit;
}
.url-input::placeholder { color: var(--muted); }
.url-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.url-row .btn-cloud { flex: 0 0 auto; }
.cloud-status { margin: 10px 0 0; font-size: 13px; color: var(--muted); min-height: 1em; }
.cloud-status.is-error { color: #ff8a8a; }

.dropzone {
	border: 2px dashed var(--border);
	border-radius: var(--radius);
	background: var(--surface-2);
	padding: 32px 20px;
	text-align: center;
	cursor: pointer;
	transition: border-color .15s, background .15s, transform .05s;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone.is-dragover {
	border-color: var(--accent);
	background: var(--accent-soft);
}
.dropzone-icon { color: var(--accent); margin-bottom: 10px; }
.dropzone-title { margin: 0 0 4px; font-weight: 600; }
.dropzone-hint { margin: 0; color: var(--muted); font-size: 14px; }
.link { color: var(--accent); text-decoration: underline; }

/* File card */
.file-card {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 14px 16px;
}
.file-meta { display: flex; align-items: center; gap: 12px; min-width: 0; }
.file-badge {
	background: var(--accent-soft);
	color: var(--accent);
	font-size: 12px;
	font-weight: 700;
	padding: 6px 10px;
	border-radius: 8px;
	letter-spacing: 0.5px;
}
.file-text { display: flex; flex-direction: column; min-width: 0; }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--muted); font-size: 13px; }
.icon-btn {
	background: transparent;
	border: 1px solid var(--border);
	color: var(--muted);
	width: 32px; height: 32px;
	border-radius: 8px;
	cursor: pointer;
	flex: none;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }

/* Options */
.options { display: flex; gap: 16px; flex-wrap: wrap; }
.option-group {
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 12px 16px;
	margin: 0;
	flex: 1 1 200px;
}
.option-group legend { color: var(--muted); font-size: 13px; padding: 0 6px; }
/* The hidden attribute must beat element display rules (e.g. .radio's inline-flex). */
[hidden] { display: none !important; }
.radio { display: inline-flex; align-items: center; gap: 6px; margin-right: 14px; cursor: pointer; }

/* Output format: full-width box with the options laid out in an aligned grid. */
.option-group--format { flex-basis: 100%; }
.fmt-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
	gap: 8px 16px;
	margin-top: 8px;
}
.fmt-grid .radio { margin-right: 0; }
.radio input { accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; margin: 4px 0; font-size: 14px; }
.check input { accent-color: var(--accent); }
.check code { font-size: 12px; }

/* Custom page dimensions */
.custom-dims { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.custom-dims input[type="number"],
.custom-dims select {
	background: var(--surface-2);
	border: 1px solid var(--border);
	color: var(--text);
	border-radius: 8px;
	padding: 6px 8px;
	font: inherit;
}
.custom-dims input[type="number"] { width: 68px; }
.custom-dims .times { color: var(--muted); }
.custom-dims input:focus, .custom-dims select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Visual crop tool */
.crop-stage {
	display: inline-block;
	max-width: 100%;
	box-sizing: border-box;
	margin: 6px 0 4px;
	padding: 14px; /* hit area: lets you drag from just outside the image to grab edge pixels */
	background: var(--surface-2);
	border-radius: 8px;
	cursor: crosshair;
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
	line-height: 0;
}
.crop-frame {
	position: relative;
	display: inline-block;
	overflow: hidden;
	line-height: 0;
	background:
		linear-gradient(45deg, #2a4d64 25%, transparent 25%, transparent 75%, #2a4d64 75%) 0 0 / 16px 16px,
		linear-gradient(45deg, #2a4d64 25%, #163243 25%, #163243 75%, #2a4d64 75%) 8px 8px / 16px 16px;
}
.crop-frame img {
	display: block;
	max-width: 100%;
	max-height: 260px;
	width: auto;
	height: auto;
	-webkit-user-drag: none;
}
.crop-sel {
	position: absolute;
	border: 1px solid #fff;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, .55), 0 0 0 9999px rgba(0, 0, 0, .45);
	pointer-events: none;
}
.crop-hint { color: var(--muted); font-size: 12px; margin: 0 0 6px; }
.link-btn {
	background: none; border: none; color: var(--accent);
	font: inherit; cursor: pointer; padding: 0 4px; text-decoration: underline;
}

/* Button */
.btn {
	border: none;
	border-radius: var(--radius);
	padding: 14px 18px;
	font-size: 16px;
	font-weight: 650;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	transition: background .15s, opacity .15s;
}
.btn-primary { background: var(--accent); color: #0b0d12; }
.btn-primary:hover:not(:disabled) { background: var(--accent-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-spinner {
	width: 16px; height: 16px;
	border: 2px solid rgba(0,0,0,.3);
	border-top-color: #0b0d12;
	border-radius: 50%;
	display: none;
	animation: spin .7s linear infinite;
}
.btn.is-loading .btn-spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Inline help note */
.option-note {
	margin: -4px 0 0;
	color: var(--muted);
	font-size: 13px;
	line-height: 1.45;
}

/* Status */
.status { margin: 0; text-align: center; font-size: 14px; min-height: 20px; }
.status.is-error { color: var(--danger); }
.status.is-ok { color: var(--ok); }

/* Steps */
.steps {
	display: flex;
	gap: 12px;
	margin-top: 28px;
	flex-wrap: nowrap;
}
.step {
	flex: 1 1 0;
	min-width: 0;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 16px;
	display: flex;
	align-items: center;
	gap: 12px;
}
.step p { margin: 0; color: var(--muted); font-size: 14px; }
.step-num {
	width: 28px; height: 28px;
	flex: none;
	display: grid;
	place-items: center;
	border-radius: 50%;
	background: var(--accent-soft);
	color: var(--accent);
	font-weight: 700;
	font-size: 14px;
}

/* Footer */
.site-footer {
	text-align: center;
	color: var(--muted);
	font-size: 13px;
	padding: 24px;
}

/* ---------------------------------------------------------------------------
   Responsive / mobile
   Two breakpoints: tablets & large phones (≤640px), then small phones (≤420px).
   The max-width containers already keep content narrow on desktop; here we mainly
   reclaim edge padding, relax the format grid, and let tight rows wrap.
   --------------------------------------------------------------------------- */
@media (max-width: 640px) {
	.site-header { padding: 14px 16px 2px; }
	.wrap { padding: 8px 16px 48px; }
	.hero { margin: 16px 0 24px; }
	.converter { padding: 16px; gap: 16px; }
	.brand-logo { max-width: 100%; }

	.options { gap: 12px; }
	.option-group { padding: 12px 14px; }
	.fmt-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px 12px; }

	/* Cloud / dropzone panels get their vertical padding back for smaller screens. */
	.cloud-panel, .dropzone { padding: 32px 16px; }

	/* Steps (if present) wrap to a 2-column grid instead of a cramped single row. */
	.steps { flex-wrap: wrap; }
	.step { flex: 1 1 45%; }
}

@media (max-width: 420px) {
	.wrap { padding: 8px 12px 40px; }
	.converter { padding: 14px; }
	.site-footer { padding: 20px 12px; }

	/* Two neat columns of formats — three is too tight to tap accurately. */
	.fmt-grid { grid-template-columns: 1fr 1fr; }

	/* Let the source tabs breathe / wrap cleanly instead of crowding one line. */
	.source-tab { padding: 7px 10px; font-size: 13px; }

	/* Custom page-dimension controls wrap rather than overflow. */
	.custom-dims { flex-wrap: wrap; }

	.steps { flex-direction: column; }
	.step { flex: 1 1 auto; }
}

/* Utility */
.visually-hidden {
	position: absolute;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}
