/* Modul Cloud — design tokens
   ---------------------------------------------------------------------------
   The single source of truth for shape, rhythm, type, motion and elevation.
   Colour does not live here: each theme preset ships its own palette file
   (css/themes/*.css) and the server loads exactly one of them, so the user's
   theme is already correct on the very first paint without any script.

   Three rules keep this layer honest:

   1. Everything the user can tune is a *number* — an alpha, a scale, a
      strength — never an on/off rule. Effects switch off by multiplying to
      zero, so no state needs a competing stylesheet or !important.

   2. Every structural choice that must survive first paint is a variable, not
      an attribute selector. The generated per-user sheet can therefore move
      the navigation to a left rail, change density or turn glass on before a
      single line of JavaScript has run.

   3. The --mt-* names are a public contract: modultalk, modulcalendar,
      modultables, modulwiki, modulnotes, modulcontacts, modultasks,
      modulassistant and the Deck fork all read them. Names are additive —
      values change, vocabulary does not shrink.

   User choices arrive from /apps/modultheme/appearance.css (generated per user,
   loaded last) and from js/appearance-core.js while the panel is open. Both
   write the properties defined below. */

@font-face {
	font-family: 'Inter';
	src: url('./../fonts/InterVariable.woff2') format('woff2');
	font-weight: 100 900;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: 'Inter';
	src: url('./../fonts/InterVariable-Italic.woff2') format('woff2');
	font-weight: 100 900;
	font-style: italic;
	font-display: swap;
}

:root {
	/* ========================================================== shape === */
	/* A strict five-step scale. The old system derived every corner from one
	   base radius, which is how a 14px slider turned buttons, rows, chips and
	   panels into the same rounded shape and flattened the hierarchy. Now each
	   step has a job, and the user's preference is a *scale factor* over the
	   whole set, so the relationships survive any setting. */
	--mt-radius-scale: 1;

	--mt-radius-xs: calc(4px * var(--mt-radius-scale));
	--mt-radius-sm: calc(6px * var(--mt-radius-scale));
	--mt-radius-md: calc(8px * var(--mt-radius-scale));
	--mt-radius-lg: calc(12px * var(--mt-radius-scale));
	--mt-radius-xl: calc(14px * var(--mt-radius-scale));

	/* Pill is a semantic shape, not a size: badges, tags, status dots, chips
	   and avatars. It deliberately does not follow the scale — a pill that is
	   only half round is just a sloppy rectangle. */
	--mt-radius-pill: 999px;

	/* Where each step belongs. Components reference these, not the raw steps,
	   so a component can never quietly pick the wrong corner. */
	--mt-radius-control: var(--mt-radius-sm);   /* button, input, nav item */
	--mt-radius-card: var(--mt-radius-md);      /* card, panel, section     */
	--mt-radius-menu: calc(10px * var(--mt-radius-scale)); /* menu, popover  */
	--mt-radius-modal: var(--mt-radius-xl);     /* dialog                   */

	/* Legacy alias: --mt-radius-base used to drive everything. Kept pointing
	   at the card step so older stylesheets stay sane. */
	--mt-radius-base: var(--mt-radius-md);

	/* ========================================================= rhythm === */
	/* ===================================================== interface scale ===
	   Плотность интерфейса — это два независимых решения, и раньше здесь было
	   только одно из них.

	   Первое принимает человек: «компактно» или «просторно», крупный шрифт или
	   мелкий. Оно живёт в --mt-density-* и --mt-type-scale и приезжает в
	   сгенерированном листе.

	   Второе принимает экран. На 2560×1440 интерфейс, нарисованный в этих
	   значениях, выглядит правильно; на ноутбуке 1366×768 те же 216 px колонки
	   и 50 px шапки съедают экран, а на 1280×720 не помещается работа. Это
	   --mt-ui-scale, и до сих пор такой величины в системе не было вовсе.

	   Перемножаются они в --mt-space-scale / --mt-control-scale /
	   --mt-font-scale — то есть в тех самых именах, которые уже читают
	   modulnotes и modultasks. Масштаб доезжает до них сам, без правок в
	   каждом приложении.

	   Ни transform: scale, ни zoom: и то и другое ломает position: fixed,
	   sticky, попперы и попадание курсора. Здесь меняются только числа, из
	   которых считаются размеры, поэтому раскладка остаётся раскладкой. */

	/* Авторежим. Лестницы по ширине и по высоте пишет css/responsive.css, и
	   берётся меньшая из двух: на ноутбуке ширины обычно хватает, а высоты
	   нет, и решать должна та сторона, которой не хватает. Считается в CSS, а
	   не в скрипте, поэтому верно уже на первой отрисовке. */
	--mt-ui-scale-w: 1;
	--mt-ui-scale-h: 1;
	--mt-ui-scale-auto: min(var(--mt-ui-scale-w), var(--mt-ui-scale-h));

	/* Выбранный вручную масштаб перебивает авторежим. Его пишет
	   сгенерированный лист (--mt-ui-scale-fixed), поэтому фиксированный
	   масштаб тоже действует до первого скрипта. Сбросить его в «авто» —
	   значит вернуть свойство в initial, и var() снова возьмёт запасное
	   значение. */
	--mt-ui-scale: var(--mt-ui-scale-fixed, var(--mt-ui-scale-auto));

	/* Уменьшать всё в одинаковое число раз нельзя: отступы терпят это легко,
	   кнопки хуже, а текст хуже всех — 14px, умноженные на 0.8, читаются как
	   уже не рабочий интерфейс. Поэтому у каждой величины своя доля общего
	   масштаба, и текст движется меньше всех. */
	--mt-ui-space-scale: var(--mt-ui-scale);
	--mt-ui-control-scale: calc(1 + (var(--mt-ui-scale) - 1) * 0.72);
	--mt-ui-font-scale: calc(1 + (var(--mt-ui-scale) - 1) * 0.45);
	/* Хром — шапка и колонка: заметно, но осторожнее отступов. */
	--mt-ui-chrome-scale: calc(1 + (var(--mt-ui-scale) - 1) * 0.8);
	--mt-ui-rail-scale: calc(1 + (var(--mt-ui-scale) - 1) * 0.85);

	/* ========================================================= rhythm === */
	/* Выбор человека. Разделены с --mt-space-scale, потому что теперь у
	   плотности два множителя, и смешивать их в одном имени значит потерять
	   возможность показать в панели, что именно выбрал пользователь. */
	--mt-density-space: 1;
	--mt-density-control: 1;

	--mt-space-scale: calc(var(--mt-density-space) * var(--mt-ui-space-scale));
	--mt-space-boost: 1;

	--mt-space-0: 0px;
	--mt-space-05: calc(2px * var(--mt-space-scale) * var(--mt-space-boost));
	--mt-space-1: calc(4px * var(--mt-space-scale) * var(--mt-space-boost));
	--mt-space-15: calc(6px * var(--mt-space-scale) * var(--mt-space-boost));
	--mt-space-2: calc(8px * var(--mt-space-scale) * var(--mt-space-boost));
	--mt-space-3: calc(12px * var(--mt-space-scale) * var(--mt-space-boost));
	--mt-space-4: calc(16px * var(--mt-space-scale) * var(--mt-space-boost));
	--mt-space-45: calc(20px * var(--mt-space-scale) * var(--mt-space-boost));
	--mt-space-5: calc(24px * var(--mt-space-scale) * var(--mt-space-boost));
	--mt-space-6: calc(32px * var(--mt-space-scale) * var(--mt-space-boost));
	--mt-space-7: calc(40px * var(--mt-space-scale) * var(--mt-space-boost));

	--mt-control-scale: calc(var(--mt-density-control) * var(--mt-ui-control-scale));
	/* Пол у каждой ступени. Кнопка, в которую трудно попасть, — не компактный
	   интерфейс, а сломанный; ниже этих величин масштаб не опускает ничего.
	   При масштабе 1 ни один пол не срабатывает даже на самой плотной
	   настройке, поэтому на большом мониторе размеры остались прежними. */
	--mt-control-sm: max(22px, calc(26px * var(--mt-control-scale)));
	--mt-control-md: max(26px, calc(32px * var(--mt-control-scale)));
	--mt-control-lg: max(30px, calc(38px * var(--mt-control-scale)));

	/* ============================================================ type === */
	--mt-type-scale: 1;
	--mt-font-scale: calc(var(--mt-type-scale) * var(--mt-ui-font-scale));
	--mt-font: 'Inter', var(--font-face, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
	--mt-font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

	/* A calm corporate ladder. Nothing in ordinary UI is allowed above 20px;
	   scale comes from weight and colour, not from size. */
	/* И пол у каждой ступени текста. Сжать интерфейс, превратив подписи в
	   микроскопические, — не решение задачи, а способ её спрятать: основной
	   текст не опускается ниже 12px ни при каком сочетании масштаба и
	   пользовательского «мелкого шрифта». */
	--mt-text-meta: max(10px, calc(11px * var(--mt-font-scale)));
	--mt-text-label: max(11px, calc(12px * var(--mt-font-scale)));
	--mt-text-compact: max(11.5px, calc(13px * var(--mt-font-scale)));
	--mt-text-ui: max(12px, calc(14px * var(--mt-font-scale)));
	--mt-text-section: max(14px, calc(16px * var(--mt-font-scale)));
	--mt-text-title: max(15px, calc(18px * var(--mt-font-scale)));
	--mt-text-display: max(16px, calc(20px * var(--mt-font-scale)));

	--mt-weight-normal: 400;
	--mt-weight-medium: 500;
	--mt-weight-semibold: 600;

	--mt-tracking-tight: -0.011em;
	--mt-tracking-caps: 0.06em;

	/* ========================================================== motion === */
	/* Short and functional. 250ms is the ceiling, and only for a whole panel
	   moving; hover is effectively instant. */
	--mt-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
	--mt-ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
	--mt-ease-in-out: cubic-bezier(0.6, 0, 0.2, 1);

	--mt-duration-instant: 90ms;
	--mt-duration-fast: 120ms;
	--mt-duration: 160ms;
	--mt-duration-slow: 200ms;
	--mt-duration-panel: 240ms;

	/* ======================================================== material === */
	/* Per-surface opacity and blur. The three material modes in the panel
	   (Чистый / Мягкий / Стекло) are nothing but a coordinated set of these,
	   computed server-side — see css/material.css for the recipes. */
	--mt-alpha-card: 1;
	--mt-alpha-content: 1;
	--mt-alpha-sidebar: 1;
	--mt-alpha-header: 1;
	--mt-alpha-modal: 1;
	--mt-alpha-menu: 1;

	--mt-blur-card: 0px;
	--mt-blur-sidebar: 0px;
	--mt-blur-rail: 0px;
	--mt-blur-header: 0px;
	--mt-blur-menu: 0px;
	--mt-blur-modal: 0px;

	/* How much of the glass character to show: the inner highlight, the lit
	   border and the saturation lift all ride this one number. */
	--mt-glass-level: 0;

	/* ======================================================= behaviour === */
	--mt-shadow-strength: 1;
	--mt-hover-strength: 1;
	--mt-hover-lift: 0px;
	--mt-glow-strength: 0;
	--mt-highlight-strength: 1;

	/* ========================================================== layout === */
	/* The MODUL Workspace layout lives entirely in these three numbers, so the
	   server can put the shell in rail mode before first paint and nothing
	   jumps when the rail's DOM arrives a moment later. */
	/* Базовая ширина — то, что выбрал пользователь; её пишет сгенерированный
	   лист. Применяемая ширина считается здесь, потому что колонка обязана
	   сужаться вместе со всем остальным: 216 px на экране 1366 — это 16 %
	   ширины, отданных списку из пятнадцати строк. */
	--mt-rail-width-base: 0px;
	--mt-rail-width: calc(var(--mt-rail-width-base) * var(--mt-ui-rail-scale));
	--mt-rail-display: none;

	/* Форма колонки. Сгенерированный лист перекрывает их под каждого
	   пользователя; значения здесь — то, как колонка выглядела до того, как у
	   неё появились настройки, поэтому старый лист остаётся рабочим. */
	--mt-rail-icon: 20px;
	--mt-rail-icon-box: 22px;
	--mt-rail-border-width: 1px;
	--mt-rail-marker-top: 9px;
	--mt-rail-marker-bottom: 9px;
	--mt-rail-marker-height: auto;
	--mt-rail-marker-width: 3px;
	--mt-rail-marker-shift: 0px;
	--mt-appmenu-display: flex;

	/* Высота шапки тоже базовая: пресеты задают свою (44…50 px), а применяемая
	   считается из неё. Пол в 40 px — ниже строка перестаёт вмещать поиск и
	   кнопку профиля одновременно. */
	--mt-header-base: 50px;
	--mt-header-height: max(40px, calc(var(--mt-header-base) * var(--mt-ui-chrome-scale)));

	/* ------------------------------------------------- панели приложений --
	   Ядро зашивает .app-navigation в 300 px, а #app-sidebar — в min-width:
	   300px. На 1280 это вместе с колонкой 516 px хрома из 1280: работать
	   негде. Ширины вынесены в переменные, css/responsive.css уменьшает их по
	   ступеням, а приложение может переопределить их у себя. */
	--mt-nav-width: calc(300px * var(--mt-ui-rail-scale));
	--mt-sidebar-width: 27vw;
	--mt-sidebar-min: 300px;
	--mt-sidebar-max: 500px;

	/* ====================================================== background === */
	--mt-bg-image: none;
	--mt-bg-size: cover;
	--mt-bg-position: center;
	--mt-bg-repeat: no-repeat;
	--mt-bg-dim: 0;
	--mt-bg-filter: none;
	--mt-bg-scale: 1;
	--mt-bg-bleed: 0px;
	--mt-bg-visible: 1;
	/* Whether a wallpaper is in play, as a number rather than a class, so the
	   decorative layers can be switched off before the first paint. The second
	   flag separates "the user picked this picture" from "this is the
	   instance's own wallpaper, which we inherited" — they are drawn from
	   different sources but must sit under the same scrim. */
	--mt-has-bg: 0;
	--mt-has-own-bg: 0;
	/* The colour the scrim is drawn in. Deliberately NOT the page colour: a
	   light wash over a photograph lightens it, the white panels above then
	   have nothing to stand out against, and the result is the milky, bleached
	   desk this redesign was supposed to remove. A scrim deepens. */
	--mt-scrim-color: #141a26;

	/* Text that sits directly on the desk rather than on a surface: the start
	   page's section labels, the greeting, the "see all" links.
	   Without a wallpaper the desk is the page colour and this is simply the
	   theme's text. With one it cannot be: measured against the catalogue, a
	   dark label on a dark photograph came out at 1.11:1. No scrim strength
	   fixes that for both a white photo and a black one, so the answer is the
	   one every video player and every desktop uses — light text with a shadow
	   under it, which is legible on essentially any image. */
	--mt-on-desk: var(--mt-text);
	--mt-on-desk-shadow: none;
	/* The scrim is what stops a photograph from bleaching the whole product.
	   It sits between the image and the interface, tinted in the page colour,
	   and the material mode decides how much of it there is. */
	--mt-scrim-alpha: 0.4;
}

/* ============================================================== derived == */
/* Composed once so no component has to know how an opacity setting becomes a
   colour, or how a shadow tone becomes an elevation. */
:root {
	--mt-surface-card: color-mix(in srgb, var(--mt-surface) calc(var(--mt-alpha-card) * 100%), transparent);
	--mt-surface-content: color-mix(in srgb, var(--mt-surface) calc(var(--mt-alpha-content) * 100%), transparent);
	--mt-surface-panel: color-mix(in srgb, var(--mt-surface-raised) calc(var(--mt-alpha-sidebar) * 100%), transparent);
	--mt-surface-header: color-mix(in srgb, var(--mt-surface-raised) calc(var(--mt-alpha-header) * 100%), transparent);
	--mt-surface-modal: color-mix(in srgb, var(--mt-surface-raised) calc(var(--mt-alpha-modal) * 100%), transparent);
	--mt-surface-menu: color-mix(in srgb, var(--mt-surface-raised) calc(var(--mt-alpha-menu) * 100%), transparent);

	/* Fields follow the sunken tone rather than the card one: an input is a
	   recess in a surface, not a translucent hole through to the wallpaper. */
	--mt-surface-field: var(--mt-surface-sunken);

	/* --- glass --------------------------------------------------------
	   Real glass is five things at once, and they are not interchangeable:
	   a tinted fill, a blur, a saturation lift (this is what keeps colour in
	   the image instead of turning it to milk), a lit top edge and a hairline
	   border that is brighter where light would catch it. Each is scaled by
	   --mt-glass-level, so at level 0 the whole recipe collapses to a plain
	   opaque surface and the same rules serve every material. */
	--mt-glass-saturate: calc(1 + 0.7 * var(--mt-glass-level));
	--mt-glass-contrast: calc(1 + 0.04 * var(--mt-glass-level));
	--mt-glass-highlight: color-mix(in srgb, var(--mt-highlight-tone) calc(var(--mt-glass-level) * 100%), transparent);
	--mt-glass-line: color-mix(in srgb, var(--mt-glass-edge) calc(var(--mt-glass-level) * 100%), var(--mt-border));

	--mt-glass-header: blur(var(--mt-blur-header)) saturate(var(--mt-glass-saturate)) contrast(var(--mt-glass-contrast));
	--mt-glass-sidebar: blur(var(--mt-blur-sidebar)) saturate(var(--mt-glass-saturate)) contrast(var(--mt-glass-contrast));
	--mt-glass-menu: blur(var(--mt-blur-menu)) saturate(var(--mt-glass-saturate));
	/* Колонка навигации получила собственное размытие: она перекрывает
	   фотографию так же, как шапка, но живёт по своим настройкам и не должна
	   зависеть от материала боковых панелей приложения. */
	--mt-glass-rail: blur(var(--mt-blur-rail)) saturate(var(--mt-glass-saturate));
	--mt-glass-modal: blur(var(--mt-blur-modal)) saturate(var(--mt-glass-saturate));
	--mt-glass-card: blur(var(--mt-blur-card)) saturate(var(--mt-glass-saturate));

	/* Legacy names kept alive for the other Modul apps. */
	--mt-glass-filter: var(--mt-glass-menu);
	--mt-glass-blur: var(--mt-blur-menu);
	--mt-glass-bg: var(--mt-surface-panel);
	--mt-glass-border: var(--mt-glass-line);

	/* --- elevation -----------------------------------------------------
	   Five levels, and a shadow means one thing only: how far an element is
	   off the surface behind it. Level 1 (navigation, the work area) is flat
	   and separated by a border; only things that genuinely float cast light.
	   The tone comes from the palette, so a dark theme gets black instead of
	   a washed blue-grey. */
	--mt-shadow-1: color-mix(in srgb, var(--mt-shadow-tone-soft) calc(var(--mt-shadow-strength) * 100%), transparent);
	--mt-shadow-2: color-mix(in srgb, var(--mt-shadow-tone) calc(var(--mt-shadow-strength) * 100%), transparent);
	--mt-shadow-3: color-mix(in srgb, var(--mt-shadow-tone-deep) calc(var(--mt-shadow-strength) * 100%), transparent);

	/* Level 1 — navigation and main surfaces: a hairline, nothing more. */
	--mt-elevation-1: 0 1px 1px var(--mt-shadow-1);
	/* Level 2 — cards and panels resting on the page. */
	--mt-elevation-2: 0 1px 2px var(--mt-shadow-1), 0 6px 18px var(--mt-shadow-2);
	/* Level 3 — menus and popovers, lifted clear of the content. */
	--mt-elevation-3: 0 2px 6px var(--mt-shadow-2), 0 8px 24px var(--mt-shadow-3);
	/* Level 4 — dialogs, above everything. */
	--mt-elevation-4: 0 24px 70px var(--mt-shadow-3), 0 4px 12px var(--mt-shadow-2);

	--mt-shadow-panel: var(--mt-elevation-2);
	--mt-shadow-popover: var(--mt-elevation-3);
	--mt-shadow-modal: var(--mt-elevation-4);

	/* Legacy aliases. */
	--mt-shadow-sm: var(--mt-elevation-1);
	--mt-shadow-md: var(--mt-elevation-2);
	--mt-shadow-lg: var(--mt-elevation-3);
	--mt-shadow-float: var(--mt-elevation-4);

	/* --- interaction ---------------------------------------------------
	   One vocabulary for every hover, selection and focus in the product, so
	   a list row in Files and a chat in the messenger react identically. */
	--mt-hover-bg: color-mix(in srgb, var(--mt-text) calc(var(--mt-hover-strength) * 5%), transparent);
	--mt-hover-bg-strong: color-mix(in srgb, var(--mt-text) calc(var(--mt-hover-strength) * 8%), transparent);
	--mt-active-bg: color-mix(in srgb, var(--mt-text) 11%, transparent);
	--mt-selected-bg: color-mix(in srgb, var(--mt-primary) calc(var(--mt-highlight-strength) * 12%), transparent);
	--mt-selected-bg-strong: color-mix(in srgb, var(--mt-primary) calc(var(--mt-highlight-strength) * 18%), transparent);
	--mt-selected-border: color-mix(in srgb, var(--mt-primary) 42%, transparent);
	--mt-focus-ring: 0 0 0 2px var(--mt-surface), 0 0 0 4px color-mix(in srgb, var(--mt-primary) 70%, transparent);

	/* The grip of a slider, a switch or any other control the user drags.
	   It is deliberately NOT a surface colour: a knob painted in --mt-surface
	   is white on a light theme and near-black on a dark one, and on a dark
	   theme that put a black hole in the middle of an accent-filled track.
	   A knob is a physical part; it stays light and catches the light in both
	   themes, the way a real one would. */
	--mt-knob: light-dark(#ffffff, #e8ebf0);
	--mt-knob-edge: color-mix(in srgb, #05070d 22%, transparent);
	/* The empty half of a track or progress bar. */
	--mt-track: color-mix(in srgb, var(--mt-text) 16%, transparent);
	--mt-disabled-opacity: 0.45;

	/* Glow is off unless asked for, and even then it is a soft ring rather
	   than a neon halo. */
	--mt-glow: 0 0 0 3px color-mix(in srgb, var(--mt-primary) calc(var(--mt-glow-strength) * 14%), transparent);
}

/* ================================================ Nextcloud integration == */

/* Re-point Nextcloud's own tokens at ours. The attribute selectors match the
   ones core themes with, so these declarations win wherever core sets a value;
   the bare `body` keeps things sane if no theme attribute is present at all. */
body,
body[data-theme-default],
body[data-theme-light],
body[data-theme-dark],
body[data-theme-light-highcontrast],
body[data-theme-dark-highcontrast] {
	--font-face: var(--mt-font);
	--default-font-size: var(--mt-text-ui);
	--font-size-small: var(--mt-text-compact);

	--color-main-background: var(--mt-surface-content);
	--color-main-background-rgb: var(--mt-surface-rgb);
	--color-main-background-translucent: var(--mt-surface-content);
	--color-main-background-blur: var(--mt-surface-panel);
	/* Deliberately none. Core applies this as a backdrop-filter on #content-vue,
	   and a backdrop-filter makes that element the containing block for every
	   fixed/absolute descendant — which detached Deck's drag ghost from the
	   cursor. Our own glass surfaces apply their filter directly, on chrome
	   only, so nothing here needs core's blur. */
	--filter-background-blur: none;
	--gradient-main-background: var(--mt-page-bg);

	--color-background-hover: var(--mt-hover-bg);
	--color-background-dark: var(--mt-surface-sunken);
	--color-background-darker: var(--mt-surface-inset);
	--color-background-selection: var(--mt-selected-bg);

	--color-main-text: var(--mt-text);
	--color-text-maxcontrast: var(--mt-text-muted);
	--color-text-maxcontrast-default: var(--mt-text-muted);
	--color-text-maxcontrast-background-blur: var(--mt-text-muted);
	--color-text-light: var(--mt-text);
	--color-placeholder-light: var(--mt-border);
	--color-placeholder-dark: var(--mt-border-strong);

	--color-border: var(--mt-border);
	--color-border-dark: var(--mt-border-strong);
	--color-border-maxcontrast: var(--mt-border-strong);

	--color-primary: var(--mt-primary);
	--color-primary-rgb: var(--mt-primary-rgb);
	--color-primary-text: var(--mt-on-primary);
	--color-primary-hover: var(--mt-primary-hover);
	--color-primary-light: var(--mt-primary-light);
	--color-primary-light-hover: var(--mt-accent-100);
	/* Text drawn ON the light primary tint. Core derives this by mixing the
	   accent into the text colour — using the raw accent instead puts blue on
	   blue, which is how the portal search field became unreadable. */
	--color-primary-light-text: var(--mt-on-primary-light);
	--color-primary-element: var(--mt-primary);
	--color-primary-element-rgb: var(--mt-primary-rgb);
	--color-primary-element-text: var(--mt-on-primary);
	--color-primary-element-text-dark: var(--mt-on-primary);
	--color-primary-element-hover: var(--mt-primary-hover);
	--color-primary-element-light: var(--mt-primary-light);
	--color-primary-element-light-hover: var(--mt-accent-100);
	--color-primary-element-light-text: var(--mt-on-primary-light);

	--color-error: var(--mt-danger);
	--color-error-hover: color-mix(in srgb, var(--mt-danger) 82%, var(--mt-text));
	--color-error-text: var(--mt-danger);
	--color-element-error: var(--mt-danger);
	--color-border-error: var(--mt-danger);
	--color-text-error: var(--mt-danger);
	--color-warning: var(--mt-warning);
	--color-warning-hover: color-mix(in srgb, var(--mt-warning) 82%, var(--mt-text));
	--color-warning-text: var(--mt-warning);
	--color-element-warning: var(--mt-warning);
	--color-success: var(--mt-success);
	--color-success-hover: color-mix(in srgb, var(--mt-success) 82%, var(--mt-text));
	--color-success-text: var(--mt-success);
	--color-element-success: var(--mt-success);
	--color-border-success: var(--mt-success);
	--color-text-success: var(--mt-success);
	--color-info: var(--mt-info);
	--color-info-hover: color-mix(in srgb, var(--mt-info) 82%, var(--mt-text));
	--color-info-text: var(--mt-info);
	--color-element-info: var(--mt-info);

	--color-box-shadow: var(--mt-shadow-2);
	--color-scrollbar: var(--mt-border-strong);
	--color-loading-light: var(--mt-surface-sunken);
	--color-loading-dark: var(--mt-border-strong);

	--border-radius: var(--mt-radius-xs);
	--border-radius-small: var(--mt-radius-xs);
	--border-radius-element: var(--mt-radius-control);
	--border-radius-container: var(--mt-radius-card);
	--border-radius-container-large: var(--mt-radius-menu);
	--border-radius-large: var(--mt-radius-menu);
	--border-radius-rounded: var(--mt-radius-pill);
	--border-radius-pill: var(--mt-radius-pill);
	--body-container-radius: var(--mt-radius-lg);

	--default-clickable-area: var(--mt-control-lg);
	--clickable-area-small: var(--mt-control-sm);
	--clickable-area-large: calc(44px * var(--mt-control-scale));
	--default-grid-baseline: calc(4px * var(--mt-space-scale));

	--animation-quick: var(--mt-duration-fast);
	--animation-slow: var(--mt-duration-slow);

	--header-height: var(--mt-header-height);
}

/* ============================================================== chrome === */

body {
	/* The page colour is painted on <html> and the wallpaper layers sit between
	   the two — see css/material.css. */
	font-family: var(--mt-font);
	font-size: var(--mt-text-ui);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

/* Scrollbars read as part of the surface rather than as a separate widget. */
* {
	scrollbar-width: thin;
	scrollbar-color: var(--mt-border-strong) transparent;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
	background: var(--mt-border-strong);
	border-radius: var(--mt-radius-pill);
	border: 3px solid transparent;
	background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--mt-text-faint); background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

::selection {
	background: color-mix(in srgb, var(--mt-primary) 24%, transparent);
}

/* One focus treatment for the whole product, and only for keyboard users. */
:focus-visible {
	outline: 2px solid var(--mt-primary);
	outline-offset: 2px;
	border-radius: var(--mt-radius-xs);
}

/*
 * An operating-system request for reduced motion outranks the user's own speed
 * setting — and it has to say so, because the generated per-user stylesheet is
 * loaded after this file and writes the same properties at the same
 * specificity. Without !important the accessibility preference lost the
 * cascade to a personalisation default, silently, on every page.
 */
@media (prefers-reduced-motion: reduce) {
	:root {
		--mt-duration-instant: 0ms !important;
		--mt-duration-fast: 0ms !important;
		--mt-duration: 0ms !important;
		--mt-duration-slow: 0ms !important;
		--mt-duration-panel: 0ms !important;
		--mt-hover-lift: 0px !important;
	}
}

/* ================================================ theme mode switching == */

/* An explicit choice. js/appearance-core.js stamps the attribute on <html> and
   <body> — the body copy is a public contract other Modul apps read. The
   attribute selectors outrank the preset's own `:root { color-scheme }`, so a
   live switch takes effect without the palette having to be re-sent. */
html[data-mt-theme='light'],
body[data-mt-theme='light'] {
	color-scheme: light;
}

html[data-mt-theme='dark'],
body[data-mt-theme='dark'] {
	color-scheme: dark;
}

/* =============================================== accent fallback scale == */
/* MODUL Blue, so a page still looks finished if the generated per-user sheet
   fails to load. Every accent the panel offers is emitted in the same shape:
   a nine-step scale plus the four semantic aliases derived from it. */
:root {
	--mt-accent-50: light-dark(#eff5ff, #0e1a2e);
	--mt-accent-100: light-dark(#dbe8fe, #132340);
	--mt-accent-200: light-dark(#bed6fd, #1a3157);
	--mt-accent-300: light-dark(#91bbfb, #24457a);
	--mt-accent-400: light-dark(#5e9bf7, #3a6cb5);
	--mt-accent-500: light-dark(#2563eb, #4f8cff);
	--mt-accent-600: light-dark(#1d4fd0, #6fa2ff);
	--mt-accent-700: light-dark(#1a44ab, #8fb8ff);
	--mt-accent-800: light-dark(#1a3b87, #b3cfff);

	--mt-primary: var(--mt-accent-500);
	--mt-primary-hover: var(--mt-accent-600);
	--mt-primary-light: var(--mt-accent-50);
	--mt-primary-soft: var(--mt-accent-100);
	--mt-accent: var(--mt-accent-400);
	--mt-secondary: var(--mt-accent-700);
	--mt-on-primary: #ffffff;
	/* Значки приложений в меню ядра: белый силуэт на фирменной поверхности.
	   Генератор переписывает это под яркость выбранного акцента. */
	--mt-appicon-filter: brightness(0) invert(1);
	--mt-on-primary-light: light-dark(#1a3b87, #b3cfff);

	--mt-primary-rgb: 37, 99, 235;
	--mt-accent-rgb: 94, 155, 247;
	--mt-secondary-rgb: 26, 68, 171;
}
