/* Modul Cloud — the Внешний вид panel
   ---------------------------------------------------------------------------
   The drawer behind the top-bar control, and the header control itself.

   The panel is held to the same rules as the rest of the product, which is the
   whole point of it: a personalisation screen that looks like a settings
   console teaches the user that the thing they are configuring is a pile of
   settings. So the type ladder here tops out at 16px, the corners come off the
   same scale as everywhere else, the segmented controls are the ones the
   product uses, and there is no 24px padding anywhere. */

/* ===================================================== header control === */

.mt-header-controls {
	display: inline-flex;
	align-items: center;
	margin-inline-end: var(--mt-space-1);
}

.mt-header-controls .mt-header-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--mt-control-lg);
	height: var(--mt-control-lg);
	padding: 0;
	border: none;
	border-radius: var(--mt-radius-control);
	background: transparent;
	color: var(--mt-text);
	cursor: pointer;
	transition:
		background-color var(--mt-duration-fast) var(--mt-ease),
		color var(--mt-duration-fast) var(--mt-ease);
}

.mt-header-controls .mt-header-btn:hover {
	background: var(--mt-hover-bg-strong);
}

.mt-header-controls .mt-header-btn:focus-visible {
	outline: 2px solid var(--mt-primary);
	outline-offset: 2px;
}

.mt-header-controls .mt-header-btn--active {
	background: var(--mt-selected-bg-strong);
	color: var(--mt-primary);
}

.mt-header-controls .mt-header-btn svg { display: block; width: 19px; height: 19px; }

/* ================================================ масштаб в шапке ====== */
/*
 * «−  90 %  +» в одной коробке: не три отдельные кнопки, а один орган
 * управления, у которого есть показание. Отсюда общая рамка, утопленная
 * подложка и разделители внутри — та же форма, что у сегментного
 * переключателя в панели, потому что это то же самое действие.
 *
 * Размеры считаются от --mt-control-*, то есть блок уменьшается вместе со
 * всем остальным интерфейсом. Управление масштабом, которое само не следует
 * масштабу, — первое, что бросается в глаза как чужеродное.
 */
.mt-header-controls .mt-scale {
	display: inline-flex;
	align-items: center;
	height: var(--mt-control-md);
	margin-inline-end: var(--mt-space-1);
	border: 1px solid var(--mt-border);
	border-radius: var(--mt-radius-control);
	background: var(--mt-surface-field);
	overflow: hidden;
}

.mt-header-controls .mt-scale__step,
.mt-header-controls .mt-scale__value {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 100%;
	margin: 0;
	padding: 0;
	min-height: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: var(--mt-text-muted);
	font: inherit;
	cursor: pointer;
	transition:
		background-color var(--mt-duration-fast) var(--mt-ease),
		color var(--mt-duration-fast) var(--mt-ease);
}

.mt-header-controls .mt-scale__step {
	width: var(--mt-control-md);
	flex: none;
}

.mt-header-controls .mt-scale__step svg {
	display: block;
	width: 15px;
	height: 15px;
}

/* Показание. Табличные цифры — чтобы строка не дёргалась при переходе с 95 на
   100: в шапке любое дрожание читается как сбой. */
.mt-header-controls .mt-scale__value {
	gap: 5px;
	min-width: 52px;
	padding-inline: var(--mt-space-2);
	border-inline: 1px solid var(--mt-border);
	font-size: var(--mt-text-label);
	font-weight: var(--mt-weight-medium);
	font-variant-numeric: tabular-nums;
	color: var(--mt-text);
	white-space: nowrap;
}

/* В авторежиме показание — не выбор человека, а вывод. Поэтому оно тише:
   приглушённый цвет отличает «столько получилось» от «столько я поставил». */
.mt-header-controls .mt-scale[data-auto='true'] .mt-scale__value {
	color: var(--mt-text-muted);
	font-weight: var(--mt-weight-normal);
}

/* Слово «Авто» — пояснение к числу, поэтому оно и набрано как пояснение, и
   уходит первым, когда шапке становится тесно. */
.mt-header-controls .mt-scale__mode {
	font-size: var(--mt-text-meta);
	letter-spacing: var(--mt-tracking-caps);
	text-transform: uppercase;
	color: var(--mt-text-faint);
}

.mt-header-controls .mt-scale__step:hover:not(:disabled),
.mt-header-controls .mt-scale__value:hover {
	background: var(--mt-hover-bg-strong);
	color: var(--mt-text);
}

.mt-header-controls .mt-scale__step:disabled {
	opacity: var(--mt-disabled-opacity);
	cursor: default;
}

.mt-header-controls .mt-scale__step:focus-visible,
.mt-header-controls .mt-scale__value:focus-visible {
	outline: 2px solid var(--mt-primary);
	outline-offset: -2px;
}

/*
 * Ниже 1280px в строке шапки одновременно живут имя приложения, поиск,
 * профиль и это. Что-то должно уйти первым, и уходит именно оно: масштаб
 * остаётся достижимым на вкладке «Интерфейс», а поиск и профиль — нет.
 * Сначала блок теряет показание и остаётся парой «− +», и только потом
 * исчезает целиком.
 */
@media (max-width: 1439px) {
	.mt-header-controls .mt-scale__mode { display: none; }
	.mt-header-controls .mt-scale__value {
		min-width: 44px;
		padding-inline: var(--mt-space-15);
	}
}

@media (max-width: 1023px) {
	.mt-header-controls .mt-scale {
		display: none;
	}
}

/* Подпись «Сейчас: 88 % — по размеру окна» под списком масштабов. */
.mt-panel .mt-row__hint--live {
	color: var(--mt-text-muted);
}

/* ============================================ control reset (core) ===== */
/*
 * Nextcloud styles every bare control in the product:
 *
 *   button:not(.button-vue,[class^=vs__]), input, textarea {
 *     width: 130px; min-height: var(--default-clickable-area); ... }
 *
 * — a fixed width, a forced minimum height, padding, a border and a background.
 * That rule is (0,1,1), so a single class on our own control does not beat it,
 * and the result was a 34x20 switch rendering as a 130x38 pill. Everything
 * this panel and the rail draw is a custom control, so the sane thing is to
 * neutralise the lot once, here, and let each component state its own size.
 *
 * Matching specificity plus later source order wins for the panel; the rail's
 * id wins outright.
 */
.mt-panel button,
.mt-panel input,
.mt-panel select,
#mt-rail button,
.mt-rail-trigger,
.mt-header-controls .mt-header-btn {
	width: auto;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	line-height: normal;
	text-align: inherit;
	cursor: pointer;
	box-sizing: border-box;
	-webkit-appearance: none;
	appearance: none;
}

.mt-panel input[type='search'],
.mt-panel input[type='range'] {
	width: 100%;
	cursor: auto;
}

.mt-panel input[type='range'] { cursor: pointer; }

/*
 * Core also paints every bare button on hover and focus —
 *   button:not(.button-vue,[class^=vs__]):hover, ...:focus {
 *     background-color: var(--color-primary-element-light-hover) }
 * — at (0,2,1), which outranks the reset above and put an accent wash behind
 * every tab, chip and switch the moment it was touched. Each component states
 * its own hover below; this clears the inherited one first.
 */
.mt-panel button:hover,
.mt-panel button:focus,
#mt-rail button:hover,
#mt-rail button:focus,
.mt-rail-trigger:hover,
.mt-rail-trigger:focus {
	background-color: transparent;
}

/*
 * And core's focus ring is `outline: 2px solid var(--color-main-text)` with a
 * 4px box-shadow, both !important — a black halo that ignores the accent and
 * clips inside our rounded controls. Replaced, at equal specificity and later
 * in the cascade, with the one ring the whole product uses.
 */
.mt-panel button:focus-visible,
.mt-panel input:focus-visible,
.mt-panel select:focus-visible,
.mt-panel summary:focus-visible,
#mt-rail button:focus-visible,
#mt-rail a:focus-visible,
.mt-rail-trigger:focus-visible {
	outline: 2px solid var(--mt-primary) !important;
	outline-offset: 2px;
	box-shadow: none !important;
}

/* ============================================================== panel === */

.mt-panel {
	position: fixed;
	inset: 0;
	z-index: 12000;
	display: flex;
	justify-content: flex-end;
	visibility: hidden;
	font-size: var(--mt-text-compact);
	color: var(--mt-text);
}

.mt-panel[data-open='true'] { visibility: visible; }

.mt-panel .mt-panel__scrim {
	position: absolute;
	inset: 0;
	background: color-mix(in srgb, #05070d 38%, transparent);
	opacity: 0;
	transition: opacity var(--mt-duration) var(--mt-ease);
}

.mt-panel[data-open='true'] .mt-panel__scrim { opacity: 1; }

/*
 * The sheet is a level-4 surface: the thing on top of everything.
 *
 * It is opaque, with no backdrop-filter, and both halves of that are load
 * bearing.
 *
 * A backdrop-filter on an element whose *contents* scroll makes the browser
 * re-composite the blurred backdrop on every frame of that scroll: the
 * background gallery ran at 29fps with it and 92 without. Moving the filter to
 * a childless pseudo-element behind the content does not help — the scrolling
 * still happens in the same stacking context, and it measured 26fps.
 *
 * Dropping the blur alone was worse than either: the sheet is 3% translucent
 * at the default material, and unblurred that 3% showed the file list behind
 * it as sharp, readable ghost text through the gallery. So the sheet stops
 * being translucent. It is a settings drawer; there is nothing behind it worth
 * seeing, and this is the one surface in the product where glass costs a third
 * of the frame rate and buys nothing.
 */
.mt-panel .mt-panel__sheet {
	position: relative;
	display: flex;
	flex-direction: column;
	width: min(420px, 100vw);
	height: 100%;
	background: var(--mt-surface-raised);
	border-inline-start: 1px solid var(--mt-border-strong);
	box-shadow: var(--mt-elevation-4);
	transform: translateX(100%);
	transition: transform var(--mt-duration-panel) var(--mt-ease);
	outline: none;
}

.mt-panel[data-open='true'] .mt-panel__sheet { transform: translateX(0); }

/* ------------------------------------------------------------- header -- */

.mt-panel .mt-panel__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--mt-space-2);
	height: 52px;
	min-height: 52px;
	padding-inline: var(--mt-space-4) var(--mt-space-2);
	border-bottom: 1px solid var(--mt-border);
}

.mt-panel .mt-panel__title {
	margin: 0;
	font-size: var(--mt-text-section);
	font-weight: var(--mt-weight-semibold);
	letter-spacing: var(--mt-tracking-tight);
	color: var(--mt-text);
}

.mt-panel .mt-panel__close {
	display: grid;
	place-items: center;
	width: var(--mt-control-md);
	height: var(--mt-control-md);
	border: 0;
	border-radius: var(--mt-radius-control);
	background: transparent;
	color: var(--mt-text-muted);
	cursor: pointer;
	transition:
		background-color var(--mt-duration-fast) var(--mt-ease),
		color var(--mt-duration-fast) var(--mt-ease);
}
.mt-panel .mt-panel__close:hover { background: var(--mt-hover-bg-strong); color: var(--mt-text); }
.mt-panel .mt-panel__close svg { width: 17px; height: 17px; }

/* --------------------------------------------------------------- tabs -- */
/*
 * Text tabs with an underline on the active one. Four filled pills across the
 * top of a drawer reads as four buttons competing for the same job; an
 * underline says "you are here" and stays out of the way.
 */
.mt-panel .mt-panel__tabs {
	display: flex;
	gap: 2px;
	padding-inline: var(--mt-space-2);
	border-bottom: 1px solid var(--mt-border);
	flex-shrink: 0;
}

.mt-panel .mt-panel__tab {
	position: relative;
	flex: 0 0 auto;
	padding: 9px var(--mt-space-3) 10px;
	border: 0;
	background: transparent;
	color: var(--mt-text-muted);
	font: inherit;
	font-weight: var(--mt-weight-medium);
	cursor: pointer;
	transition: color var(--mt-duration-fast) var(--mt-ease);
}

.mt-panel .mt-panel__tab:hover { color: var(--mt-text); }

.mt-panel .mt-panel__tab[aria-selected='true'] {
	color: var(--mt-text);
	font-weight: var(--mt-weight-semibold);
}

.mt-panel .mt-panel__tab[aria-selected='true']::after {
	content: '';
	position: absolute;
	inset-inline: var(--mt-space-2);
	bottom: -1px;
	height: 2px;
	border-radius: 2px 2px 0 0;
	background: var(--mt-primary);
}

.mt-panel .mt-panel__tab:focus-visible { outline: 2px solid var(--mt-primary); outline-offset: -2px; }

/* --------------------------------------------------------------- body -- */

.mt-panel .mt-panel__body {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: var(--mt-space-3) var(--mt-space-4) var(--mt-space-4);
}

.mt-panel .mt-tabpanel {
	display: flex;
	flex-direction: column;
	gap: var(--mt-space-45);
}

/*
 * `hidden` is a presentation hint with the specificity of a UA default, so any
 * author rule that sets `display` beats it — which is how three hidden tab
 * panels ended up stacked under the visible one. Every element in this panel
 * that JavaScript hides is a flex container, so the reinstatement has to be
 * explicit and it has to win.
 */
.mt-panel [hidden] {
	display: none !important;
}

.mt-panel .mt-panel__foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--mt-space-2);
	height: 48px;
	min-height: 48px;
	padding-inline: var(--mt-space-4) var(--mt-space-3);
	border-top: 1px solid var(--mt-border);
}

.mt-panel .mt-panel__status {
	font-size: var(--mt-text-label);
	color: var(--mt-text-muted);
}
.mt-panel .mt-panel__status[data-state='ok'] { color: var(--mt-success); }
.mt-panel .mt-panel__status[data-state='error'] { color: var(--mt-danger); }

/* ======================================================= building blocks == */

.mt-panel .mt-group {
	display: flex;
	flex-direction: column;
	gap: var(--mt-space-2);
}

.mt-panel .mt-group__head {
	display: flex;
	flex-direction: column;
	gap: 1px;
}

.mt-panel .mt-group__title {
	margin: 0;
	font-size: var(--mt-text-label);
	font-weight: var(--mt-weight-semibold);
	letter-spacing: var(--mt-tracking-caps);
	text-transform: uppercase;
	color: var(--mt-text-faint);
}

.mt-panel .mt-group__hint,
.mt-panel .mt-note {
	margin: 0;
	font-size: var(--mt-text-label);
	line-height: 1.45;
	color: var(--mt-text-muted);
}

/* Label left, control right — until the control cannot share the line, at
   which point it wraps to its own full-width row rather than squeezing the
   label into three characters. */
.mt-panel .mt-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--mt-space-1) var(--mt-space-3);
	min-height: 30px;
}

.mt-panel .mt-row > .mt-seg,
.mt-panel .mt-row > .mt-range,
.mt-panel .mt-row > .mt-select {
	margin-inline-start: auto;
}

.mt-panel .mt-row__text {
	display: flex;
	flex-direction: column;
	gap: 1px;
	min-width: 0;
}

.mt-panel .mt-row__label {
	font-size: var(--mt-text-compact);
	font-weight: var(--mt-weight-medium);
	color: var(--mt-text);
}

.mt-panel .mt-row__hint {
	font-size: var(--mt-text-meta);
	line-height: 1.35;
	color: var(--mt-text-faint);
}

.mt-panel .mt-stack {
	display: flex;
	flex-direction: column;
	gap: var(--mt-space-2);
	transition: opacity var(--mt-duration) var(--mt-ease);
}

.mt-panel .mt-stack[data-disabled='true'],
.mt-panel .mt-row[data-disabled='true'] {
	opacity: var(--mt-disabled-opacity);
	pointer-events: none;
}

.mt-panel .mt-notice {
	padding: var(--mt-space-2) var(--mt-space-3);
	border: 1px solid var(--mt-border);
	border-inline-start: 3px solid var(--mt-primary);
	border-radius: var(--mt-radius-control);
	background: var(--mt-surface-sunken);
	font-size: var(--mt-text-label);
	line-height: 1.5;
	color: var(--mt-text-muted);
}
.mt-panel .mt-notice strong { color: var(--mt-text); font-weight: var(--mt-weight-semibold); }

/* ----------------------------------------------------------- controls -- */

/*
 * Segmented control: one recessed track, one raised segment. The raised
 * segment carries the card surface and a hairline shadow, which is what makes
 * it read as *selected* rather than as one of three outlined buttons.
 */
.mt-panel .mt-seg {
	display: inline-flex;
	gap: 2px;
	padding: 2px;
	border: 1px solid var(--mt-border);
	border-radius: var(--mt-radius-control);
	background: var(--mt-surface-sunken);
	flex-shrink: 0;
}

/* Набор из четырёх и более вариантов переезжает на свою строку целиком и
   переносится внутри: иначе последний вариант уходит за край панели. */
.mt-panel .mt-seg--wrap {
	flex-wrap: wrap;
	justify-content: flex-start;
}

.mt-panel .mt-row > .mt-seg--wrap {
	margin-inline-start: 0;
	width: 100%;
}

.mt-panel .mt-seg__btn {
	flex: 0 0 auto;
	padding: 4px 10px;
	border: 0;
	border-radius: calc(var(--mt-radius-control) - 2px);
	background: transparent;
	color: var(--mt-text-muted);
	font: inherit;
	font-size: var(--mt-text-label);
	font-weight: var(--mt-weight-medium);
	white-space: nowrap;
	cursor: pointer;
	transition:
		background-color var(--mt-duration-fast) var(--mt-ease),
		color var(--mt-duration-fast) var(--mt-ease),
		box-shadow var(--mt-duration-fast) var(--mt-ease);
}

.mt-panel .mt-seg__btn:hover { color: var(--mt-text); }

.mt-panel .mt-seg__btn[aria-checked='true'] {
	background: var(--mt-surface);
	color: var(--mt-text);
	font-weight: var(--mt-weight-semibold);
	box-shadow: var(--mt-elevation-1);
}

.mt-panel .mt-seg__btn:focus-visible { outline: 2px solid var(--mt-primary); outline-offset: 1px; }

.mt-panel .mt-seg[data-disabled='true'] {
	opacity: var(--mt-disabled-opacity);
	cursor: not-allowed;
}

/* Switch: 34×20, the size a switch is. */
.mt-panel .mt-switch {
	position: relative;
	width: 34px;
	height: 20px;
	min-width: 34px;
	min-height: 20px;
	padding: 0;
	border: 1px solid var(--mt-border-strong);
	border-radius: var(--mt-radius-pill);
	background: var(--mt-surface-sunken);
	cursor: pointer;
	flex-shrink: 0;
	transition:
		background-color var(--mt-duration-fast) var(--mt-ease),
		border-color var(--mt-duration-fast) var(--mt-ease);
}

.mt-panel .mt-switch__knob {
	position: absolute;
	top: 2px;
	inset-inline-start: 2px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: var(--mt-text-faint);
	transition:
		transform var(--mt-duration-fast) var(--mt-ease),
		background-color var(--mt-duration-fast) var(--mt-ease);
}

.mt-panel .mt-switch[aria-checked='true'] {
	background: var(--mt-primary);
	border-color: var(--mt-primary);
}

.mt-panel .mt-switch[aria-checked='true'] .mt-switch__knob {
	background: var(--mt-on-primary);
	transform: translateX(14px);
}

.mt-panel .mt-switch:focus-visible { outline: 2px solid var(--mt-primary); outline-offset: 2px; }

/* Slider: a filled track that shows its own position. */
.mt-panel .mt-range {
	display: flex;
	align-items: center;
	gap: var(--mt-space-2);
	min-width: 190px;
}

.mt-panel .mt-range input[type='range'] {
	flex: 1 1 auto;
	height: 18px;
	margin: 0;
	appearance: none;
	background: transparent;
	cursor: pointer;
}

.mt-panel .mt-range input[type='range']::-webkit-slider-runnable-track {
	height: 4px;
	border-radius: var(--mt-radius-pill);
	/* The unfilled part is a tint of the text colour rather than the sunken
	   surface: on a dark theme the sunken surface is within two points of the
	   panel behind it, so the track simply disappeared. */
	background: linear-gradient(
		to right,
		var(--mt-primary) 0,
		var(--mt-primary) var(--mt-range-pos, 50%),
		var(--mt-track) var(--mt-range-pos, 50%),
		var(--mt-track) 100%
	);
	border: none;
}

.mt-panel .mt-range input[type='range']::-moz-range-track {
	height: 4px;
	border-radius: var(--mt-radius-pill);
	background: var(--mt-track);
	border: none;
}
.mt-panel .mt-range input[type='range']::-moz-range-progress {
	height: 4px;
	border-radius: var(--mt-radius-pill);
	background: var(--mt-primary);
}

.mt-panel .mt-range input[type='range']::-webkit-slider-thumb {
	appearance: none;
	width: 15px;
	height: 15px;
	margin-top: -6.5px;
	border: 1px solid var(--mt-knob-edge);
	border-radius: 50%;
	background: var(--mt-knob);
	box-shadow: 0 1px 2px rgba(5, 7, 13, 0.28);
	transition: border-color var(--mt-duration-fast) var(--mt-ease),
		box-shadow var(--mt-duration-fast) var(--mt-ease);
}
.mt-panel .mt-range input[type='range']:hover::-webkit-slider-thumb {
	border-color: var(--mt-primary);
	box-shadow: 0 1px 3px rgba(5, 7, 13, 0.36);
}

.mt-panel .mt-range input[type='range']::-moz-range-thumb {
	width: 13px;
	height: 13px;
	border: 1px solid var(--mt-knob-edge);
	border-radius: 50%;
	background: var(--mt-knob);
}

.mt-panel .mt-range input[type='range']:focus-visible { outline: 2px solid var(--mt-primary); outline-offset: 2px; }
.mt-panel .mt-range input[type='range']:disabled { cursor: not-allowed; }

.mt-panel .mt-range__value {
	min-width: 42px;
	font-size: var(--mt-text-meta);
	font-variant-numeric: tabular-nums;
	text-align: end;
	color: var(--mt-text-muted);
}

.mt-panel .mt-select {
	height: var(--mt-control-md);
	max-width: 180px;
	padding-inline: var(--mt-space-2);
	border: 1px solid var(--mt-border);
	border-radius: var(--mt-radius-control);
	background: var(--mt-surface-field);
	color: var(--mt-text);
	font: inherit;
	font-size: var(--mt-text-label);
	cursor: pointer;
}

.mt-panel .mt-btn {
	height: var(--mt-control-md);
	padding-inline: var(--mt-space-3);
	border: 1px solid transparent;
	border-radius: var(--mt-radius-control);
	background: transparent;
	color: var(--mt-text-muted);
	font: inherit;
	font-size: var(--mt-text-label);
	font-weight: var(--mt-weight-medium);
	cursor: pointer;
	transition:
		background-color var(--mt-duration-fast) var(--mt-ease),
		color var(--mt-duration-fast) var(--mt-ease);
}
.mt-panel .mt-btn--ghost:hover { background: var(--mt-hover-bg-strong); color: var(--mt-text); }

/* Disclosure. */
.mt-panel .mt-more {
	border: 1px solid var(--mt-border);
	border-radius: var(--mt-radius-card);
	background: var(--mt-surface-sunken);
}

.mt-panel .mt-more__summary {
	display: flex;
	align-items: center;
	gap: var(--mt-space-2);
	padding: var(--mt-space-2) var(--mt-space-3);
	cursor: pointer;
	list-style: none;
	user-select: none;
}
.mt-panel .mt-more__summary::-webkit-details-marker { display: none; }

.mt-panel .mt-more__title {
	flex: none;
	white-space: nowrap;
	font-size: var(--mt-text-compact);
	font-weight: var(--mt-weight-medium);
	color: var(--mt-text);
}

.mt-panel .mt-more__hint {
	flex: 1 1 auto;
	font-size: var(--mt-text-meta);
	color: var(--mt-text-faint);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.mt-panel .mt-more__chevron {
	display: grid;
	place-items: center;
	color: var(--mt-text-faint);
	transition: transform var(--mt-duration-fast) var(--mt-ease);
}
.mt-panel .mt-more__chevron svg { width: 14px; height: 14px; }
.mt-panel .mt-more[open] .mt-more__chevron { transform: rotate(90deg); }

.mt-panel .mt-more__body {
	display: flex;
	flex-direction: column;
	gap: var(--mt-space-2);
	padding: var(--mt-space-1) var(--mt-space-3) var(--mt-space-3);
	border-top: 1px solid var(--mt-border);
}

/* ========================================================= theme cards == */

.mt-panel .mt-presets {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: var(--mt-space-2);
}

.mt-panel .mt-preset {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: var(--mt-space-15);
	padding: var(--mt-space-15);
	border: 1px solid var(--mt-border);
	border-radius: var(--mt-radius-card);
	background: var(--mt-surface-card);
	text-align: start;
	cursor: pointer;
	transition:
		border-color var(--mt-duration-fast) var(--mt-ease),
		box-shadow var(--mt-duration-fast) var(--mt-ease);
}

.mt-panel .mt-preset:hover { border-color: var(--mt-border-strong); }

/* Selected: a 1px accent border and a small tick. No glow, no scale, no
   coloured card — the thumbnail is already the loudest thing in the tile and
   it does not need a halo around it. */
.mt-panel .mt-preset[aria-pressed='true'] {
	border-color: var(--mt-primary);
	box-shadow: 0 0 0 1px var(--mt-primary);
}

.mt-panel .mt-preset:focus-visible { outline: 2px solid var(--mt-primary); outline-offset: 2px; }

.mt-panel .mt-preset__tick {
	position: absolute;
	top: 12px;
	inset-inline-end: 12px;
	display: none;
	place-items: center;
	width: 17px;
	height: 17px;
	border-radius: 50%;
	background: var(--mt-primary);
	color: var(--mt-on-primary);
}
.mt-panel .mt-preset__tick svg { width: 11px; height: 11px; stroke-width: 3; }
.mt-panel .mt-preset[aria-pressed='true'] .mt-preset__tick { display: grid; }

.mt-panel .mt-preset__meta {
	display: flex;
	flex-direction: column;
	gap: 1px;
	padding-inline: 3px;
	padding-bottom: 2px;
}

.mt-panel .mt-preset__name {
	font-size: var(--mt-text-compact);
	font-weight: var(--mt-weight-semibold);
	color: var(--mt-text);
}

.mt-panel .mt-preset__tagline {
	font-size: var(--mt-text-meta);
	line-height: 1.35;
	color: var(--mt-text-faint);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* ---- the miniature ---------------------------------------------------
   A real small interface: rail or navigation, a header with a search field,
   a content surface and three message rows. Everything is a couple of pixels
   tall, so the only things that survive are the ones that actually
   distinguish the themes — the layout, the palette and the accent. */

.mt-panel .mt-thumb {
	display: flex;
	height: 78px;
	border: 1px solid;
	border-radius: var(--mt-radius-control);
	overflow: hidden;
}

.mt-panel .mt-thumb__rail {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 3px;
	/* Wide enough to read as a column rather than as a border. It is the one
	   thing this card exists to communicate. */
	width: 18px;
	padding-top: 5px;
	flex-shrink: 0;
}

.mt-panel .mt-thumb__railitem {
	width: 10px;
	height: 5px;
	border-radius: 2px;
}

.mt-panel .mt-thumb__main {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-width: 0;
}

.mt-panel .mt-thumb__header {
	display: flex;
	align-items: center;
	gap: 4px;
	height: 12px;
	padding-inline: 4px;
	border-bottom: 1px solid;
	flex-shrink: 0;
}

.mt-panel .mt-thumb__mark {
	width: 6px;
	height: 6px;
	border-radius: 1.5px;
	flex-shrink: 0;
}

.mt-panel .mt-thumb__field {
	width: 34px;
	height: 5px;
	border: 1px solid;
	border-radius: 2px;
}

.mt-panel .mt-thumb__split {
	display: flex;
	flex: 1 1 auto;
	gap: 3px;
	padding: 3px;
	min-height: 0;
}

.mt-panel .mt-thumb__nav {
	width: 26px;
	padding: 4px 3px;
	border: 1px solid;
	border-radius: 3px;
	flex-shrink: 0;
}

.mt-panel .mt-thumb__navitem {
	display: block;
	height: 4px;
	margin-bottom: 4px;
	border-radius: 1.5px;
}

.mt-panel .mt-thumb__content {
	display: flex;
	flex-direction: column;
	gap: 4px;
	flex: 1 1 auto;
	min-width: 0;
	padding: 5px;
	border: 1px solid;
	border-radius: 3px;
}

.mt-panel .mt-thumb__bubble {
	display: block;
	height: 7px;
	border-radius: 3px;
}
.mt-panel .mt-thumb__bubble--in { width: 62%; }
.mt-panel .mt-thumb__bubble--out { width: 48%; align-self: flex-end; }
.mt-panel .mt-thumb__bubble--short { width: 40%; }

/* ============================================================= accents == */

.mt-panel .mt-accents {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: var(--mt-space-15);
}

.mt-panel .mt-accent {
	position: relative;
	display: flex;
	align-items: center;
	gap: var(--mt-space-2);
	padding: 5px 7px;
	border: 1px solid var(--mt-border);
	border-radius: var(--mt-radius-control);
	background: var(--mt-surface-card);
	text-align: start;
	cursor: pointer;
	transition:
		border-color var(--mt-duration-fast) var(--mt-ease),
		background-color var(--mt-duration-fast) var(--mt-ease);
}

.mt-panel .mt-accent:hover { border-color: var(--mt-border-strong); background: var(--mt-surface-inset); }

.mt-panel .mt-accent[aria-pressed='true'] {
	border-color: var(--mt-primary);
	box-shadow: 0 0 0 1px var(--mt-primary);
}

.mt-panel .mt-accent:focus-visible { outline: 2px solid var(--mt-primary); outline-offset: 2px; }

/* Three steps of the ramp, not one dot: the accent choice is a choice of
   scale, and the tints are what most of the interface is actually drawn in. */
.mt-panel .mt-accent__ramp {
	display: flex;
	width: 30px;
	height: 16px;
	border-radius: var(--mt-radius-xs);
	overflow: hidden;
	flex-shrink: 0;
	box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mt-text) 10%, transparent);
}

.mt-panel .mt-accent__stop { flex: 1 1 auto; }

.mt-panel .mt-accent__name {
	flex: 1 1 auto;
	font-size: var(--mt-text-label);
	font-weight: var(--mt-weight-medium);
	color: var(--mt-text);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.mt-panel .mt-accent__tick {
	display: none;
	place-items: center;
	color: var(--mt-primary);
}
.mt-panel .mt-accent__tick svg { width: 13px; height: 13px; stroke-width: 2.6; }
.mt-panel .mt-accent[aria-pressed='true'] .mt-accent__tick { display: grid; }

.mt-panel .mt-custom {
	display: flex;
	align-items: center;
	gap: var(--mt-space-2);
}

.mt-panel .mt-custom__picker {
	width: 30px;
	height: 26px;
	padding: 2px;
	border: 1px solid var(--mt-border);
	border-radius: var(--mt-radius-xs);
	background: var(--mt-surface-card);
	cursor: pointer;
}

.mt-panel .mt-custom__apply {
	height: 26px;
	padding-inline: var(--mt-space-2);
	border: 1px solid var(--mt-border);
	border-radius: var(--mt-radius-control);
	background: var(--mt-surface-card);
	color: var(--mt-text-muted);
	font: inherit;
	font-size: var(--mt-text-label);
	cursor: pointer;
}
.mt-panel .mt-custom[data-on='true'] .mt-custom__apply {
	border-color: var(--mt-primary);
	color: var(--mt-primary);
}

/* =========================================================== materials == */

.mt-panel .mt-materials {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: var(--mt-space-15);
}

.mt-panel .mt-material {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: var(--mt-space-1);
	padding: var(--mt-space-1);
	border: 1px solid var(--mt-border);
	border-radius: var(--mt-radius-card);
	background: var(--mt-surface-card);
	text-align: start;
	cursor: pointer;
	transition: border-color var(--mt-duration-fast) var(--mt-ease);
}

.mt-panel .mt-material:hover { border-color: var(--mt-border-strong); }

.mt-panel .mt-material[aria-pressed='true'] {
	border-color: var(--mt-primary);
	box-shadow: 0 0 0 1px var(--mt-primary);
}

.mt-panel .mt-material:focus-visible { outline: 2px solid var(--mt-primary); outline-offset: 2px; }

/*
 * The swatch is the demonstration: a strip of colour standing in for a
 * photograph, with a panel laid over it at that mode's real opacity and real
 * blur. Three words could not tell the difference between "мягкий" and
 * "стекло"; forty pixels of the actual effect can.
 */
.mt-panel .mt-material__art {
	position: relative;
	height: 42px;
	border-radius: var(--mt-radius-xs);
	overflow: hidden;
	/* A busy, high-contrast ground. A pale one would let all three modes look
	   the same — the whole job of this swatch is to show the difference. */
	background:
		linear-gradient(118deg,
			var(--mt-accent-700) 0%,
			var(--mt-accent-400) 38%,
			var(--mt-warning) 62%,
			var(--mt-accent-800) 100%);
}

.mt-panel .mt-material__art::after {
	/* A hard edge for the blur to actually have something to smear. */
	content: '';
	position: absolute;
	inset: 0;
	/* Hard edges, so the blur has something to actually smear. */
	background:
		radial-gradient(circle at 20% 26%, rgba(255, 255, 255, 0.92) 0 20%, transparent 21%),
		radial-gradient(circle at 78% 72%, rgba(0, 0, 0, 0.62) 0 26%, transparent 27%),
		repeating-linear-gradient(58deg, rgba(255, 255, 255, 0.22) 0 3px, transparent 3px 9px);
}

.mt-panel .mt-material__sheet {
	position: absolute;
	inset: 9px 7px;
	z-index: 1;
	border-radius: 3px;
	background: color-mix(in srgb, var(--mt-surface) calc(var(--mt-demo-alpha, 1) * 100%), transparent);
	backdrop-filter: blur(var(--mt-demo-blur, 0px)) saturate(calc(1 + 0.7 * var(--mt-demo-glass, 0)));
	-webkit-backdrop-filter: blur(var(--mt-demo-blur, 0px)) saturate(calc(1 + 0.7 * var(--mt-demo-glass, 0)));
	border: 1px solid color-mix(in srgb, var(--mt-glass-edge) calc(var(--mt-demo-glass, 0) * 100%), var(--mt-border));
	box-shadow: inset 0 1px 0 color-mix(in srgb, var(--mt-highlight-tone) calc(var(--mt-demo-glass, 0) * 100%), transparent);
}

.mt-panel .mt-material__meta {
	padding: 0 3px 2px;
}

.mt-panel .mt-material__name {
	font-size: var(--mt-text-label);
	font-weight: var(--mt-weight-semibold);
	color: var(--mt-text);
}

/* One line under the row describes whichever mode is selected. Three hints
   inside three 125px cards could only ever be three clipped fragments. */
.mt-panel .mt-materials__hint {
	margin: 0;
	font-size: var(--mt-text-meta);
	line-height: 1.4;
	color: var(--mt-text-muted);
}

/* ================================================ приложения в панели === */

.mt-panel .mt-applist {
	display: flex;
	flex-direction: column;
	gap: 1px;
}

.mt-panel .mt-applist__row {
	display: flex;
	align-items: center;
	gap: var(--mt-space-2);
	min-height: 30px;
	padding: 2px var(--mt-space-1);
	border-radius: var(--mt-radius-control);
	cursor: grab;
	transition: background-color var(--mt-duration-fast) var(--mt-ease);
}

.mt-panel .mt-applist__row:hover { background: var(--mt-hover-bg-strong); }
.mt-panel .mt-applist__row[data-dragging='true'] { opacity: 0.4; }

.mt-panel .mt-applist__grip {
	display: grid;
	place-items: center;
	width: 16px;
	color: var(--mt-text-faint);
	flex: none;
}
.mt-panel .mt-applist__grip svg { width: 16px; height: 16px; }

.mt-panel .mt-applist__name {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: var(--mt-text-compact);
	color: var(--mt-text);
}

/* ============================================================ the фон === */

.mt-panel .mt-finder {
	display: flex;
	align-items: center;
	gap: var(--mt-space-1);
	height: var(--mt-control-md);
	padding-inline: var(--mt-space-2) 3px;
	border: 1px solid var(--mt-border);
	border-radius: var(--mt-radius-control);
	background: var(--mt-surface-field);
	color: var(--mt-text-faint);
	transition: border-color var(--mt-duration-fast) var(--mt-ease);
}

.mt-panel .mt-finder:focus-within { border-color: var(--mt-primary); }
.mt-panel .mt-finder > svg { width: 15px; height: 15px; flex-shrink: 0; }

.mt-panel .mt-finder input[type='search'] {
	flex: 1 1 auto;
	min-width: 0;
	height: 100%;
	border: 0 !important;
	background: transparent !important;
	box-shadow: none !important;
	color: var(--mt-text);
	font: inherit;
	font-size: var(--mt-text-compact);
	outline: none;
}

.mt-panel .mt-finder__upload {
	display: grid;
	place-items: center;
	width: 26px;
	height: 26px;
	border: 0;
	border-radius: var(--mt-radius-xs);
	background: transparent;
	color: var(--mt-text-muted);
	cursor: pointer;
	flex-shrink: 0;
	transition: background-color var(--mt-duration-fast) var(--mt-ease);
}
.mt-panel .mt-finder__upload:hover { background: var(--mt-hover-bg-strong); color: var(--mt-text); }
.mt-panel .mt-finder__upload svg { width: 15px; height: 15px; }
.mt-panel .mt-finder__upload[data-busy='true'] { opacity: 0.5; pointer-events: none; }

/* Categories: quiet text tabs. The grid is the subject of this screen. */
/*
 * One scrolling line. There are fourteen categories, and wrapped they took
 * four rows — a third of the drawer spent on filters, with the gallery pushed
 * below the fold. The grid is the subject of this screen; the categories are
 * how you get to it.
 */
.mt-panel .mt-cats {
	display: flex;
	flex-wrap: nowrap;
	gap: var(--mt-space-1);
	margin-top: calc(var(--mt-space-2) * -1);
	padding-bottom: 3px;
	border-bottom: 1px solid var(--mt-border);
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scrollbar-width: none;
	/* Fades the last chip rather than cutting it, so there is a visible cue
	   that the row continues. */
	-webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
	mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
}

.mt-panel .mt-cats::-webkit-scrollbar { height: 0; }

.mt-panel .mt-cat {
	position: relative;
	/* The row scrolls, so the chips must keep their natural width instead of
	   being squeezed into each other by the flex container. */
	flex: 0 0 auto;
	padding: 5px var(--mt-space-2) 6px;
	border: 0;
	background: transparent;
	color: var(--mt-text-muted);
	font: inherit;
	font-size: var(--mt-text-label);
	font-weight: var(--mt-weight-medium);
	cursor: pointer;
	white-space: nowrap;
	transition: color var(--mt-duration-fast) var(--mt-ease);
}
.mt-panel .mt-cat:hover { color: var(--mt-text); }
.mt-panel .mt-cat[aria-selected='true'] { color: var(--mt-text); }
.mt-panel .mt-cat[aria-selected='true']::after {
	content: '';
	position: absolute;
	inset-inline: 6px;
	bottom: -1px;
	height: 2px;
	border-radius: 2px 2px 0 0;
	background: var(--mt-primary);
}
.mt-panel .mt-cat:focus-visible { outline: 2px solid var(--mt-primary); outline-offset: -2px; }

.mt-panel .mt-gallery {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: var(--mt-space-15);
	border-radius: var(--mt-radius-card);
	transition: box-shadow var(--mt-duration-fast) var(--mt-ease);
}

.mt-panel .mt-gallery[data-dragging='true'] {
	box-shadow: 0 0 0 2px var(--mt-primary);
}

.mt-panel .mt-bg-card {
	position: relative;
	aspect-ratio: 16 / 10;
	/* Lets the browser skip layout and paint for tiles that are far off
	   screen. The intrinsic size keeps the scrollbar honest while they are
	   skipped, so the thumb does not jump as you scroll. */
	content-visibility: auto;
	contain-intrinsic-size: auto 84px;
	border: 1px solid var(--mt-border);
	border-radius: var(--mt-radius-control);
	background-color: var(--mt-surface-sunken);
	background-size: cover;
	background-position: center;
	cursor: pointer;
	overflow: hidden;
	transition:
		border-color var(--mt-duration-fast) var(--mt-ease),
		box-shadow var(--mt-duration-fast) var(--mt-ease);
}

.mt-panel .mt-bg-card:hover { border-color: var(--mt-border-strong); }

.mt-panel .mt-bg-card[aria-pressed='true'] {
	border-color: var(--mt-primary);
	box-shadow: 0 0 0 1px var(--mt-primary);
}

.mt-panel .mt-bg-card:focus-visible { outline: 2px solid var(--mt-primary); outline-offset: 2px; }

.mt-panel .mt-bg-card__label {
	position: absolute;
	inset-inline: 0;
	bottom: 0;
	padding: 10px 5px 3px;
	background: linear-gradient(to top, rgba(6, 9, 14, 0.72), transparent);
	color: #fff;
	font-size: var(--mt-text-meta);
	font-weight: var(--mt-weight-medium);
	text-align: start;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	opacity: 0;
	transition: opacity var(--mt-duration-fast) var(--mt-ease);
}
.mt-panel .mt-bg-card:hover .mt-bg-card__label,
.mt-panel .mt-bg-card:focus-visible .mt-bg-card__label { opacity: 1; }

.mt-panel .mt-bg-card__tick {
	position: absolute;
	top: 5px;
	inset-inline-start: 5px;
	display: none;
	place-items: center;
	width: 17px;
	height: 17px;
	border-radius: 50%;
	background: var(--mt-primary);
	color: var(--mt-on-primary);
}
.mt-panel .mt-bg-card__tick svg { width: 11px; height: 11px; stroke-width: 3; }
.mt-panel .mt-bg-card[aria-pressed='true'] .mt-bg-card__tick { display: grid; }

.mt-panel .mt-bg-card__action {
	position: absolute;
	top: 4px;
	inset-inline-end: 4px;
	display: grid;
	place-items: center;
	width: 22px;
	height: 22px;
	border: 0;
	border-radius: var(--mt-radius-xs);
	background: color-mix(in srgb, #06090e 55%, transparent);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	color: #fff;
	cursor: pointer;
	opacity: 0;
	transition: opacity var(--mt-duration-fast) var(--mt-ease);
}
.mt-panel .mt-bg-card__action svg { width: 12px; height: 12px; }
.mt-panel .mt-bg-card__action--del { inset-inline-end: 30px; }
.mt-panel .mt-bg-card:hover .mt-bg-card__action,
.mt-panel .mt-bg-card__action:focus-visible { opacity: 1; }
.mt-panel .mt-bg-card__action--fav[data-on='true'] {
	opacity: 1;
	color: var(--mt-warning);
}
.mt-panel .mt-bg-card__action--fav[data-on='true'] svg { fill: currentColor; }

.mt-panel .mt-bg-card--none {
	display: grid;
	place-items: center;
	gap: 2px;
	align-content: center;
	background-image: none;
	background-color: var(--mt-surface-sunken);
	color: var(--mt-text-muted);
	font-size: var(--mt-text-meta);
	font-weight: var(--mt-weight-medium);
}
.mt-panel .mt-bg-card--none svg { width: 15px; height: 15px; }

.mt-panel .mt-empty {
	grid-column: 1 / -1;
	padding: var(--mt-space-5) var(--mt-space-3);
	border: 1px dashed var(--mt-border-strong);
	border-radius: var(--mt-radius-card);
	color: var(--mt-text-faint);
	font-size: var(--mt-text-label);
	text-align: center;
}

/* ========================================================== responsive == */

@media (max-width: 520px) {
	.mt-panel .mt-panel__sheet {
		width: 100vw;
		border-inline-start: none;
	}
	.mt-panel .mt-presets { grid-template-columns: 1fr; }
	.mt-panel .mt-accents { grid-template-columns: 1fr; }
	.mt-panel .mt-row {
		flex-direction: column;
		align-items: stretch;
		gap: var(--mt-space-1);
	}
	.mt-panel .mt-seg { align-self: flex-start; }
}

/* A short window loses the drawer's breathing room before it loses a control. */
@media (max-height: 640px) {
	.mt-panel .mt-tabpanel { gap: var(--mt-space-3); }
	.mt-panel .mt-thumb { height: 62px; }
}

/* Вкладка «Панель» без включённой колонки: не прячем её, а приглушаем —
   исчезающая вкладка читается как поломка, а не как «здесь пока нечего». */
.mt-panel .mt-panel__tab[data-quiet='true'] {
	opacity: 0.55;
}
