/* OpenTranslate switcher — theme-agnostic, accessible, no dependencies. */
.otr-switcher {
	--otr-bg: #ffffff;
	--otr-fg: #1d2327;
	--otr-muted: #646970;
	--otr-border: rgba(0, 0, 0, 0.12);
	--otr-hover: rgba(0, 0, 0, 0.05);
	--otr-active: rgba(34, 113, 177, 0.1);
	--otr-accent: #2271b1;
	--otr-radius: 8px;
	--otr-shadow: 0 10px 30px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.06);
	position: relative;
	display: inline-flex;
	align-items: center;
	color: var(--otr-fg);
	font-size: 14px;
	line-height: 1.3;
	text-align: start;
}

.otr-switcher *,
.otr-switcher *::before,
.otr-switcher *::after {
	box-sizing: border-box;
}

.otr-toggle {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	margin: 0;
	padding: 7px 10px;
	border: 1px solid var(--otr-border);
	border-radius: var(--otr-radius);
	background: var(--otr-bg);
	color: inherit;
	font: inherit;
	line-height: 1.2;
	cursor: pointer;
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

.otr-toggle:hover,
.otr-toggle:focus-visible {
	background: var(--otr-hover);
	border-color: rgba(0, 0, 0, 0.22);
}

.otr-toggle:focus-visible {
	outline: 2px solid var(--otr-accent);
	outline-offset: 2px;
}

.otr-flag {
	display: inline-block;
	font-size: 1.05em;
	line-height: 1;
}

.otr-label {
	font-weight: 600;
	white-space: nowrap;
}

.otr-chevron {
	width: 16px;
	height: 16px;
	flex: 0 0 auto;
	opacity: 0.65;
	transition: transform 0.15s ease;
}

.otr-switcher.is-open .otr-chevron {
	transform: rotate(180deg);
}

.otr-menu {
	position: absolute;
	z-index: 1000;
	top: calc(100% + 6px);
	inset-inline-start: 0;
	min-width: 220px;
	max-height: min(60vh, 380px);
	margin: 0;
	padding: 6px;
	overflow: auto;
	list-style: none;
	background: var(--otr-bg);
	border: 1px solid var(--otr-border);
	border-radius: var(--otr-radius);
	box-shadow: var(--otr-shadow);
	display: none;
}

.otr-switcher.is-open .otr-menu {
	display: block;
}

.otr-menu li {
	margin: 0;
	padding: 0;
}

.otr-item {
	display: flex;
	align-items: center;
	gap: 9px;
	padding: 8px 10px;
	border-radius: 6px;
	color: var(--otr-fg);
	text-decoration: none;
	white-space: nowrap;
}

.otr-item:hover,
.otr-item:focus-visible {
	background: var(--otr-hover);
	color: var(--otr-fg);
	outline: none;
}

.otr-item:focus-visible {
	box-shadow: inset 0 0 0 2px var(--otr-accent);
}

.otr-item.is-active {
	background: var(--otr-active);
	font-weight: 600;
}

.otr-name {
	flex: 1 1 auto;
}

.otr-check {
	width: 16px;
	height: 16px;
	margin-inline-start: auto;
	color: var(--otr-accent);
}

.otr-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Inline variant */
.otr-switcher--inline {
	display: block;
}

.otr-inline-list {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px 6px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.otr-inline-list li {
	margin: 0;
	padding: 0;
}

.otr-switcher--inline .otr-item {
	display: inline-flex;
	padding: 5px 8px;
	border: 1px solid transparent;
}

.otr-switcher--inline .otr-item.is-active {
	border-color: var(--otr-border);
}

/* Floating variant */
.otr-floating {
	position: fixed;
	z-index: 99999;
}

.otr-position--bottom-right {
	right: 20px;
	bottom: 20px;
}

.otr-position--bottom-left {
	left: 20px;
	bottom: 20px;
}

.otr-position--top-right {
	right: 20px;
	top: 20px;
}

.otr-position--top-left {
	left: 20px;
	top: 20px;
}

.otr-position--bottom-right .otr-menu,
.otr-position--bottom-left .otr-menu {
	top: auto;
	bottom: calc(100% + 8px);
}

.otr-position--bottom-right .otr-menu,
.otr-position--top-right .otr-menu {
	inset-inline-start: auto;
	inset-inline-end: 0;
}

.otr-floating .otr-toggle {
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

@media (prefers-color-scheme: dark) {
	.otr-switcher {
		--otr-bg: #1e2329;
		--otr-fg: #f0f0f1;
		--otr-muted: #a7aaad;
		--otr-border: rgba(255, 255, 255, 0.16);
		--otr-hover: rgba(255, 255, 255, 0.08);
		--otr-active: rgba(114, 174, 230, 0.18);
		--otr-accent: #72aee6;
		--otr-shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
	}
}

@media (max-width: 480px) {
	.otr-menu {
		min-width: min(260px, calc(100vw - 32px));
	}
}
