:root {
	--bg: #08080a;
	--surface: #151518;
	--surface-2: #1e1e22;
	--border: #28282d;
	--border-soft: #1e1e22;
	--orange: #ff9000;
	--text: #eceef0;
	--text-dim: #8b8b93;
	--text-faint: #57575e;
	--danger: #ff5b5f;
	--radius: 10px;
	--radius-lg: 20px;
	--control-gap: 10px;
	--control-icon: 18px;
	--sans: 'Inter', ui-sans-serif;
	--mono: 'JetBrains Mono', ui-monospace;
	--ease: cubic-bezier(0.22, 0.9, 0.32, 1);
}

* {
	box-sizing: border-box;
}

html,
body {
	height: 100%;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: var(--sans);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 32px 16px;
	min-height: 100vh;
	overflow-x: hidden;
}

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

.app {
	position: relative;
	z-index: 1;
	width: 100%;
	max-width: 460px;
	display: flex;
	flex-direction: column;
	gap: 18px;
}

.tabs {
	position: relative;
	display: grid;
	grid-template-columns: 1fr 1fr;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 4px;
}
.tab {
	position: relative;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--control-gap);
	padding: 11px 16px;
	border: 0;
	background: transparent;
	color: var(--text-dim);
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.02em;
	border-radius: 999px;
	cursor: pointer;
}
.tab[aria-selected='true'] {
	color: #0a0a0b;
}
.tab-icon,
.icon-link,
.icon-key {
	width: var(--control-icon);
	height: var(--control-icon);
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}
.tab-indicator {
	position: absolute;
	z-index: 1;
	top: 4px;
	left: 4px;
	bottom: 4px;
	width: calc(50% - 4px);
	background: var(--orange);
	border-radius: 999px;
}
.tab-indicator.pos-fetch {
	left: 50%;
}

.stage {
	position: relative;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	display: flex;
}
.stage.mode-upload {
	padding: 28px;
	min-height: 220px;
}
.stage.mode-fetch {
	padding: 10px;
	min-height: 0;
}
.panel {
	position: relative;
	z-index: 1;
	width: 100%;
	display: flex;
}
.panel[hidden] {
	display: none;
}

.dropzone {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	border: 1.5px dashed var(--border);
	border-radius: var(--radius);
	cursor: pointer;
	padding: 20px;
	transition:
		border-color 0.25s var(--ease),
		background-color 0.25s var(--ease);
}
.dropzone:hover,
.dropzone:focus-visible {
	border-color: var(--text-faint);
}
.dropzone.is-drag {
	border-color: var(--orange);
	background: rgba(255, 145, 0, 0.07);
}
.icon-cloud-big {
	width: 46px;
	height: 46px;
	color: var(--text-dim);
	display: inline-flex;
}
.tab-icon svg,
.icon-cloud-big svg,
.icon-link svg,
.icon-key svg {
	width: 100%;
	height: 100%;
}
.dropzone.is-drag .icon-cloud-big {
	color: var(--orange);
}

.drop-hint {
	margin: 0;
	text-align: center;
	font-size: 12px;
	color: var(--text-faint);
	max-width: 220px;
	line-height: 1.5;
}
.drop-hint kbd {
	font-family: var(--mono);
	font-size: 10.5px;
	background: var(--surface-2);
	color: var(--text-dim);
	border: 1px solid var(--border);
	border-radius: 5px;
	padding: 1.5px 5px;
	margin: 0 1px;
}

.linkzone {
	flex: 1;
	display: flex;
	align-items: center;
	gap: var(--control-gap);
	border: 1.5px solid var(--border);
	border-radius: var(--radius);
	padding: 0 8px 0 16px;
	transition: border-color 0.25s var(--ease);
}
.linkzone:focus-within {
	border-color: var(--orange);
}
.linkzone > .icon-link {
	color: var(--text-dim);
}
#url-input {
	flex: 1;
	min-width: 0;
	padding: 16px 0;
	background: transparent;
	border: 0;
	outline: 0;
	color: var(--text);
	font: inherit;
	font-size: 13.5px;
}
#url-input::placeholder {
	color: var(--text-faint);
}
.btn-send {
	flex-shrink: 0;
	width: 38px;
	height: 38px;
	border-radius: 999px;
	border: 0;
	background: var(--surface-2);
	color: var(--text-dim);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}
.btn-send svg {
	width: 16px;
	height: 16px;
}
.btn-send:hover {
	background: var(--orange);
	color: #0a0a0b;
}
.token-row {
	display: flex;
	align-items: center;
	gap: var(--control-gap);
	height: 52px;
	padding: 0 14px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
}
.icon-key {
	color: var(--text-dim);
}
#token-input {
	flex: 1;
	min-width: 0;
	background: transparent;
	border: 0;
	outline: 0;
	color: var(--text);
	font-family: var(--mono);
	font-size: 13px;
	letter-spacing: 0.05em;
}
#token-input::placeholder {
	color: var(--text-faint);
	letter-spacing: 0.02em;
	font-family: var(--sans);
}
.icon-btn {
	flex-shrink: 0;
	width: 30px;
	height: 30px;
	border-radius: 8px;
	border: 0;
	background: transparent;
	color: var(--text-dim);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}
.icon-btn svg {
	width: 16px;
	height: 16px;
}
.icon-btn:hover {
	background: var(--surface-2);
	color: var(--text);
}
.token-dot {
	flex-shrink: 0;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--text-faint);
}
.token-dot.ok {
	background: var(--orange);
}
.token-dot.bad {
	background: var(--danger);
}

.queue {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.history {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	overflow: hidden;
}
.history-summary {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 16px;
	color: var(--text-dim);
	font-size: 13px;
	font-weight: 600;
	list-style: none;
	cursor: pointer;
}
.history-summary::-webkit-details-marker {
	display: none;
}
.history-summary::after {
	content: '+';
	font-size: 18px;
	font-weight: 400;
	line-height: 1;
}
.history[open] .history-summary::after {
	content: '−';
}
.history-summary:hover {
	color: var(--text);
}
.history-count {
	margin-left: auto;
	color: var(--text-faint);
	font-size: 11px;
	font-weight: 500;
}
.history-list {
	max-height: 320px;
	padding: 0 8px 8px;
	overflow-y: auto;
}
.history-list .row {
	background: var(--surface-2);
	border-color: transparent;
}

.row {
	display: flex;
	align-items: center;
	gap: 12px;
	background: var(--surface);
	border: 1px solid var(--border-soft);
	border-radius: var(--radius);
	padding: 10px 12px;
}

.row-icon {
	flex-shrink: 0;
	width: 34px;
	height: 34px;
	border-radius: 8px;
	background: var(--surface-2);
	color: var(--text-dim);
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}
.row-icon svg {
	width: 17px;
	height: 17px;
}
.row-icon img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.row.is-error .row-icon {
	color: var(--danger);
}

.row-body {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 5px;
}
.row-title {
	font-size: 12.5px;
	color: var(--text);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.row-title a {
	color: inherit;
	text-decoration: none;
}
.row-title a:hover {
	color: var(--orange);
}
.row-meta {
	font-size: 11px;
	color: var(--text-faint);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.row-meta.is-error {
	color: var(--danger);
}

.row-progress {
	display: none;
	height: 3px;
	border-radius: 2px;
	background: var(--surface-2);
	overflow: hidden;
}
.row.is-active .row-progress {
	display: block;
}
.row-progress-bar {
	height: 100%;
	width: 0%;
	background: var(--orange);
}
.row.is-active:not(.is-indeterminate) .row-progress-bar {
	transition: width 0.15s linear;
}
.row.is-active.is-indeterminate .row-progress-bar {
	width: 38%;
	animation: indet 1.2s ease-in-out infinite;
}
@keyframes indet {
	0% {
		transform: translateX(-100%);
	}
	100% {
		transform: translateX(260%);
	}
}

.row-actions {
	flex-shrink: 0;
	display: flex;
	gap: 2px;
}

.spin {
	animation: spin 1s linear infinite;
	transform-origin: center;
}
@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

.toasts {
	position: fixed;
	left: 50%;
	bottom: 24px;
	transform: translateX(-50%);
	z-index: 50;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	pointer-events: none;
	width: min(92vw, 340px);
}
.toast {
	pointer-events: auto;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 11px 20px;
	font-size: 12.5px;
	color: var(--text);
	text-align: center;
}
.toast.error {
	color: var(--danger);
	border-color: rgba(255, 91, 95, 0.35);
}
.toast.success {
	color: var(--orange);
	border-color: rgba(255, 145, 0, 0.35);
}
.toast svg {
	width: 15px;
	height: 15px;
	flex-shrink: 0;
}
::-webkit-scrollbar {
	width: 8px;
	height: 8px;
}
::-webkit-scrollbar-thumb {
	background: var(--surface-2);
	border-radius: 4px;
}

@media (max-width: 420px) {
	body {
		padding: 20px 14px;
	}
	.stage.mode-upload {
		padding: 22px;
		min-height: 190px;
	}
	.row-meta {
		max-width: 120px;
	}
}

@media (prefers-reduced-motion: reduce) {
	* {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
	}
}
