/* CardScan — дизайн-система пульта IPS OS (D:\IPS_OS\panel\static\css\base.css) в
   контрастной редакции ImPuls Mails (D:\ImPuls_Mails\app\static\css\ips.css): токены
   светлой и тёмной темы, фон «северное сияние» с сеткой, стекло, кнопки, поля,
   переключатели, сегменты, статусы, аватары, появление, тосты, диалоги.
   Компоненты самого приложения — в app.css. Цвет числом в правилах app.css не пишется —
   сначала токен здесь.

   Тема по умолчанию — системная; переключатель закрепляет противоположную
   (data-theme на <html>, выбор — localStorage «cardscan.theme», см. js/ui.js). */

:root {
  color-scheme: light dark;

  --font: "Segoe UI Variable Text", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: "Cascadia Mono", "Cascadia Code", Consolas, ui-monospace, monospace;

  /* Общий язык пульта: фиолетово-циановый акцент */
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --accent-grad: linear-gradient(135deg, #8b5cf6 0%, #6366f1 50%, #22d3ee 100%);
  --accent-glow: rgb(124 92 255 / .6);
  /* основная кнопка: циан пульта только в полосах и графиках — под белым текстом он дал бы контраст < 2:1 */
  --accent-grad-btn: linear-gradient(135deg, #8b5cf6 0%, #6366f1 52%, #2563eb 100%);
  /* Фирменный цвет CardScan в пульте — бирюзовый (D:\IPS_OS\apps.yaml): знак, плитка */
  --brand: #14b8a6;
  --brand-grad: linear-gradient(135deg, #5eead4 0%, #14b8a6 48%, #0d9488 100%);
  --brand-text: #0f766e;

  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --info: #38bdf8;
  --idle: #94a3b8;

  --radius-xs: 6px;
  --radius-s: 10px;
  --radius: 16px;
  --radius-l: 22px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);

  /* светлая тема */
  --bg: #eef1f8;
  --bg-2: #e6eaf4;
  --surface: rgb(255 255 255 / .72);         /* стекло: верхняя панель, меню */
  --surface-strong: rgb(255 255 255 / .92);  /* тосты, диалоги */
  --surface-solid: #ffffff;
  --card: rgb(255 255 255 / .84);            /* карточки: без размытия фона — легче для машины на весь день */
  --surface-2: rgb(15 23 42 / .035);
  --surface-3: rgb(15 23 42 / .065);
  --border: rgb(15 23 42 / .08);
  --border-strong: rgb(15 23 42 / .15);
  --control-border: rgb(15 23 42 / .24);     /* рамка полей: 3:1 к фону */
  --field-bg: #ffffff;
  --text: #0f172a;
  --text-2: #475569;                          /* пояснения: 7:1 */
  --text-3: #6b7588;                          /* подписи второго плана, подсказки в полях: 4.6:1 */
  --accent-text: #5b3fe0;                     /* ссылки и акцент в тексте: 5.9:1 на белом */
  --pill-mix: 55%;                            /* цвет статуса в тексте плашки: смесь с --text */
  --shadow: 0 1px 2px rgb(15 23 42 / .05), 0 8px 24px -8px rgb(15 23 42 / .12);
  --shadow-l: 0 2px 4px rgb(15 23 42 / .04), 0 24px 48px -16px rgb(15 23 42 / .22);
  --aurora-1: rgb(139 92 246 / .22);
  --aurora-2: rgb(34 211 238 / .20);
  --aurora-3: rgb(20 184 166 / .14);
  --grid-line: rgb(15 23 42 / .045);
  --scroll-thumb: rgb(15 23 42 / .22);
  --scrim: rgb(15 23 42 / .35);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

}

/* тёмная тема: по системе (если не закреплена светлая) и по выбору */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #070a12;
    --bg-2: #0b0f1a;
    --surface: rgb(20 26 40 / .66);
    --surface-strong: rgb(24 31 47 / .92);
    --surface-solid: #111726;
    --card: rgb(19 25 39 / .78);
    --surface-2: rgb(255 255 255 / .035);
    --surface-3: rgb(255 255 255 / .075);
    --border: rgb(255 255 255 / .075);
    --border-strong: rgb(255 255 255 / .14);
    --control-border: rgb(255 255 255 / .2);
    --field-bg: rgb(255 255 255 / .045);
    --text: #e8ecf5;
    --text-2: #a3aec2;
    --text-3: #7f8aa0;
    --accent-text: #b3a6ff;
    --brand-text: #5eead4;
    --pill-mix: 72%;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 12px 32px -12px rgb(0 0 0 / .6);
    --shadow-l: 0 2px 6px rgb(0 0 0 / .35), 0 28px 60px -20px rgb(0 0 0 / .75);
    --aurora-1: rgb(124 92 255 / .30);
    --aurora-2: rgb(34 211 238 / .15);
    --aurora-3: rgb(20 184 166 / .12);
    --grid-line: rgb(255 255 255 / .035);
    --scroll-thumb: rgb(255 255 255 / .2);
    --scrim: rgb(2 4 10 / .55);
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  }
}
:root[data-theme="dark"] {
  --bg: #070a12;
  --bg-2: #0b0f1a;
  --surface: rgb(20 26 40 / .66);
  --surface-strong: rgb(24 31 47 / .92);
  --surface-solid: #111726;
  --card: rgb(19 25 39 / .78);
  --surface-2: rgb(255 255 255 / .035);
  --surface-3: rgb(255 255 255 / .075);
  --border: rgb(255 255 255 / .075);
  --border-strong: rgb(255 255 255 / .14);
  --control-border: rgb(255 255 255 / .2);
  --field-bg: rgb(255 255 255 / .045);
  --text: #e8ecf5;
  --text-2: #a3aec2;
  --text-3: #7f8aa0;
  --accent-text: #b3a6ff;
  --brand-text: #5eead4;
  --pill-mix: 72%;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 12px 32px -12px rgb(0 0 0 / .6);
  --shadow-l: 0 2px 6px rgb(0 0 0 / .35), 0 28px 60px -20px rgb(0 0 0 / .75);
  --aurora-1: rgb(124 92 255 / .30);
  --aurora-2: rgb(34 211 238 / .15);
  --aurora-3: rgb(20 184 166 / .12);
  --grid-line: rgb(255 255 255 / .035);
  --scroll-thumb: rgb(255 255 255 / .2);
  --scrim: rgb(2 4 10 / .55);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

*, *::before, *::after { box-sizing: border-box; }

html {
  accent-color: var(--accent);
  scrollbar-color: var(--scroll-thumb) transparent;
  scrollbar-width: thin;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font: 14px/1.45 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

::selection { background: color-mix(in srgb, var(--accent) 32%, transparent); }

h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; letter-spacing: -.01em; }
[x-cloak] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

.icon { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: middle; }
.icon.s { width: 15px; height: 15px; }
.icon.xs { width: 13px; height: 13px; }
.icon.l { width: 22px; height: 22px; }

/* --- фон: северное сияние и сетка ------------------------------------------ */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background: var(--bg);
}
/* сетка — отдельным слоем, чтобы маска гасила только её, а не сияние */
.backdrop b {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(var(--grid-line) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px) 0 0 / 44px 44px;
  mask-image: radial-gradient(ellipse 110% 80% at 50% 0%, #000 40%, transparent 100%);
}
/* Пятна сияния — мягкие радиальные градиенты без filter: blur(): приложение открыто весь день,
   а сдвиг готовой текстуры видеокарта делает почти даром (размытие пришлось бы считать каждый кадр) */
.backdrop::before,
.backdrop::after,
.backdrop i {
  content: "";
  position: absolute;
  border-radius: 50%;
  will-change: transform;
}
.backdrop::before {
  width: 62vw; height: 62vw; left: -16vw; top: -26vw;
  background: radial-gradient(circle, var(--aurora-1), color-mix(in srgb, var(--aurora-1) 45%, transparent) 30%, transparent 70%);
  animation: drift-a 26s ease-in-out infinite alternate;
}
.backdrop::after {
  width: 56vw; height: 56vw; right: -18vw; top: -12vw;
  background: radial-gradient(circle, var(--aurora-2), color-mix(in srgb, var(--aurora-2) 45%, transparent) 30%, transparent 70%);
  animation: drift-b 32s ease-in-out infinite alternate;
}
.backdrop i {
  width: 46vw; height: 46vw; left: 28vw; top: 38vh;
  background: radial-gradient(circle, var(--aurora-3), color-mix(in srgb, var(--aurora-3) 45%, transparent) 30%, transparent 70%);
  animation: drift-c 38s ease-in-out infinite alternate;
}
@keyframes drift-a { to { transform: translate(8vw, 6vh) scale(1.15); } }
@keyframes drift-b { to { transform: translate(-6vw, 10vh) scale(.9); } }
@keyframes drift-c { to { transform: translate(-10vw, -8vh) scale(1.2); } }

/* --- стекло и карточки ------------------------------------------------------- */

.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
}

/* --- кнопки ------------------------------------------------------------------ */

.btn {
  --b-bg: var(--surface-2);
  --b-fg: var(--text);
  --b-bd: var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border-radius: 11px;
  border: 1px solid var(--b-bd);
  background: var(--b-bg);
  color: var(--b-fg);
  font: 500 13.5px/1 var(--font);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  transition: transform .18s var(--ease), background-color .2s, border-color .2s, box-shadow .2s, opacity .2s, color .2s;
  user-select: none;
}
.btn:hover { background: var(--surface-3); border-color: color-mix(in srgb, var(--text) 24%, transparent); }
.btn:active { transform: scale(.96); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled, .btn.disabled, .btn.busy { opacity: .5; pointer-events: none; box-shadow: none; }
.btn .icon { transition: transform .3s var(--ease-spring); }
.btn:hover .icon { transform: scale(1.1); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 9px; gap: 6px; }
.btn.sm .icon { width: 14px; height: 14px; }
.btn.wide { width: 100%; height: 42px; font-size: 14.5px; border-radius: 13px; }
.btn.icon-only { width: 34px; padding: 0; }
.btn.sm.icon-only { width: 28px; }

.btn.primary {
  --b-fg: #fff;
  --b-bd: transparent;
  background: var(--accent-grad-btn);
  text-shadow: 0 1px 1px rgb(30 20 90 / .3);
  box-shadow: 0 6px 20px -6px var(--accent-glow), inset 0 1px 0 rgb(255 255 255 / .25);
}
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 10px 28px -8px rgb(124 92 255 / .75), inset 0 1px 0 rgb(255 255 255 / .3); }
/* блик, пробегающий по основной кнопке */
.btn.primary::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(110deg, transparent 30%, rgb(255 255 255 / .35) 50%, transparent 70%);
  translate: -120% 0;
  transition: translate .7s var(--ease);
}
.btn.primary:hover::after { translate: 120% 0; }
.btn.go { --b-bg: color-mix(in srgb, var(--ok) 14%, transparent); --b-fg: color-mix(in srgb, var(--ok) var(--pill-mix), var(--text)); --b-bd: color-mix(in srgb, var(--ok) 35%, transparent); }
.btn.go:hover { background: color-mix(in srgb, var(--ok) 22%, transparent); }
.btn.danger { --b-bg: color-mix(in srgb, var(--bad) 12%, transparent); --b-fg: color-mix(in srgb, var(--bad) var(--pill-mix), var(--text)); --b-bd: color-mix(in srgb, var(--bad) 32%, transparent); }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 20%, transparent); }
/* «Удалить» рядом с обычными кнопками: красный текст, фон — при наведении */
.btn.danger-ghost { --b-fg: color-mix(in srgb, var(--bad) var(--pill-mix), var(--text)); }
.btn.danger-ghost:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.btn.ghost { --b-bg: transparent; --b-bd: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
/* нажатая кнопка-переключатель («Перенос текста») */
.btn.on { --b-bg: color-mix(in srgb, var(--accent) 14%, transparent); --b-bd: color-mix(in srgb, var(--accent) 45%, transparent); --b-fg: var(--accent-text); }

.link { background: none; border: 0; color: var(--accent-text); cursor: pointer; font: inherit; padding: 0; text-decoration: none; border-radius: 4px; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.spin { animation: spin .9s linear infinite; }
@keyframes spin { to { rotate: 360deg; } }

/* --- поля ввода ------------------------------------------------------------------
   В приложении поля без классов — оформляем сами элементы. */

input, select, textarea {
  font: 13.5px/1.4 var(--font);
  color: var(--text);
  background-color: var(--field-bg);
  border: 1px solid var(--control-border);
  border-radius: 10px;
  padding: 6px 11px;
  min-height: 34px;
  transition: border-color .2s, box-shadow .2s, background-color .2s;
}
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--text) 38%, transparent); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:disabled, select:disabled, textarea:disabled { background-color: var(--surface-2); border-color: var(--border); color: var(--text-3); }
textarea { resize: vertical; }
select {
  appearance: none;
  padding-right: 32px;
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 15px;
  cursor: pointer;
}
select option { color: var(--text); background: var(--surface-solid); }
input[type=checkbox], input[type=radio] { min-height: 0; width: 16px; height: 16px; margin: 0; padding: 0; accent-color: var(--accent); cursor: pointer; box-shadow: none; }
input[type=file] { min-height: 0; }
input[type=color] { padding: 2px; min-height: 0; }
input[type=search]::-webkit-search-cancel-button { cursor: pointer; }

/* переключатель: чекбокс, нарисованный тумблером */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; color: var(--text-2); user-select: none; }
.switch input[type=checkbox] {
  appearance: none;
  width: 36px; height: 21px;
  border-radius: 99px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  position: relative;
  flex: none;
  transition: background-color .25s var(--ease), border-color .25s;
}
.switch input[type=checkbox]::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / .3);
  transition: translate .3s var(--ease-spring);
}
.switch input[type=checkbox]:checked { background: var(--accent); border-color: transparent; }
.switch input[type=checkbox]:checked::after { translate: 15px 0; }
.switch input[type=checkbox]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: none; }

/* сегменты: вкладки внутри раздела */
.segmented { display: inline-flex; flex-wrap: wrap; padding: 3px; gap: 2px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--border); }
.segmented > button { border: 0; background: none; color: var(--text-2); font: 500 13px/1 var(--font); min-height: 30px; padding: 0 12px; border-radius: 10px; cursor: pointer; transition: background-color .2s, color .2s, box-shadow .2s; display: inline-flex; align-items: center; gap: 7px; }
.segmented > button:hover { color: var(--text); }
.segmented > button.on { background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow); }
.segmented > button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* --- статусы ------------------------------------------------------------------- */

.orb {
  --c: var(--idle);
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c);
  position: relative;
  flex: none;
  box-shadow: 0 0 12px color-mix(in srgb, var(--c) 70%, transparent);
}
.orb.up { --c: var(--ok); }
.orb.warn { --c: var(--warn); }
.orb.starting { --c: var(--info); }
.orb.down { --c: var(--bad); }
.orb.off { --c: var(--idle); box-shadow: none; }
.orb.up::after, .orb.down::after, .orb.warn::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid var(--c);
  animation: ping 2.4s cubic-bezier(0, 0, .2, 1) infinite;
}
.orb.down::after { animation-duration: 1.2s; }
.orb.starting { animation: breathe 1.1s ease-in-out infinite; }
@keyframes ping { 0% { scale: .5; opacity: .9; } 80%, 100% { scale: 2.1; opacity: 0; } }
@keyframes breathe { 50% { opacity: .35; scale: .8; } }

/* inline-block, а не flex: так длинная подпись в узкой колонке обрезается многоточием */
.pill {
  --c: var(--idle);
  display: inline-block;
  height: 22px;
  max-width: 100%;
  padding: 0 9px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
  color: color-mix(in srgb, var(--c) var(--pill-mix), var(--text));
  background: color-mix(in srgb, var(--c) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 28%, transparent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 21px;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--text-2);
  white-space: nowrap;
  vertical-align: middle;
}
.badge.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: color-mix(in srgb, var(--ok) var(--pill-mix), var(--text)); }
.badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: color-mix(in srgb, var(--warn) var(--pill-mix), var(--text)); }
.badge.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: color-mix(in srgb, var(--bad) var(--pill-mix), var(--text)); }
.badge.tint { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent-text); }

/* аватар с инициалами: оттенок --h — от имени */
.avatar {
  --h: 250;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  font: 700 11.5px/1 var(--font);
  color: #fff;
  background: linear-gradient(135deg, hsl(var(--h) 70% 58%), hsl(calc(var(--h) + 40) 72% 46%));
  box-shadow: 0 0 0 2px var(--surface-solid);
  letter-spacing: .02em;
}

/* --- появление ------------------------------------------------------------------ */

.rise {
  animation: rise .55s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 55ms);
}
@keyframes rise { from { opacity: 0; translate: 0 12px; scale: .985; } }
.fade-in { animation: fade .45s var(--ease) both; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; scale: .6; } }

.skeleton {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%) 0 0 / 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* --- тосты (popover="manual", js/ui.js) --------------------------------------- */

.toast {
  --c: var(--accent);
  position: fixed;
  inset: auto 20px auto auto;
  bottom: calc(20px + var(--y, 0px));
  margin: 0;
  width: min(400px, calc(100vw - 32px));
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px 12px 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: var(--shadow-l);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  font-size: 13px;
  line-height: 1.45;
  overflow: visible;
  opacity: 1;
  translate: 0 0;
  transition: opacity .35s var(--ease), translate .45s var(--ease-spring), bottom .35s var(--ease), display .45s, overlay .45s;
  transition-behavior: allow-discrete;
}
.toast:not(:popover-open):not(.no-popover) { opacity: 0; translate: 30px 0; }
.toast.leaving { opacity: 0; translate: 30px 0; }
@starting-style { .toast:popover-open { opacity: 0; translate: 40px 0; } }
.toast::before { content: ""; position: absolute; left: 0; top: 11px; bottom: 11px; width: 3px; border-radius: 3px; background: var(--c); }
.toast.ok { --c: var(--ok); }
.toast.error { --c: var(--bad); }
.toast.warn { --c: var(--warn); }
.toast > .icon { color: var(--c); margin-top: 1px; }
.toast .msg { flex: 1; min-width: 0; overflow-wrap: anywhere; white-space: pre-line; }
.toast button { flex: none; margin: -2px -2px 0 0; border: 0; background: none; color: var(--text-3); cursor: pointer; padding: 3px; border-radius: 7px; display: grid; place-items: center; }
.toast button:hover { color: var(--text); background: var(--surface-3); }
.toast button:focus-visible { outline: 2px solid var(--accent); }
/* полоска оставшегося времени */
.toast .ttl { position: absolute; left: 14px; right: 14px; bottom: 5px; height: 2px; border-radius: 2px; background: color-mix(in srgb, var(--c) 45%, transparent); transform-origin: left; animation: ttl linear forwards; animation-duration: var(--ttl, 4500ms); opacity: .7; }
.toast:hover .ttl { animation-play-state: paused; }
@keyframes ttl { to { transform: scaleX(0); } }

/* --- диалоги ------------------------------------------------------------------- */

dialog.modal {
  width: min(520px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 40px);
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-l);
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: var(--shadow-l);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  overflow: auto;
  opacity: 1;
  scale: 1;
  translate: 0 0;
  transition: opacity .25s var(--ease), scale .35s var(--ease-spring), translate .35s var(--ease), display .35s, overlay .35s;
  transition-behavior: allow-discrete;
}
dialog.modal.wide { width: min(1200px, calc(100vw - 32px)); }
dialog.modal:not([open]) { opacity: 0; scale: .95; translate: 0 8px; }
@starting-style { dialog.modal[open] { opacity: 0; scale: .92; translate: 0 12px; } }
dialog.modal::backdrop {
  background: var(--scrim);
  backdrop-filter: blur(4px);
  opacity: 1;
  transition: opacity .3s, display .3s, overlay .3s;
  transition-behavior: allow-discrete;
}
dialog.modal:not([open])::backdrop { opacity: 0; }
@starting-style { dialog.modal[open]::backdrop { opacity: 0; } }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 20px 22px 6px; }
.modal-head h3 { font-size: 17px; font-weight: 650; min-width: 0; overflow-wrap: anywhere; }
.modal-head .btn { margin-left: auto; }
.modal-body { padding: 10px 22px 6px; }
.modal-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; padding: 14px 22px 20px; }
.modal-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: color-mix(in srgb, var(--c, var(--accent)) 16%, transparent); color: var(--c, var(--accent)); }
.confirm-text { margin: 0; color: var(--text-2); white-space: pre-line; overflow-wrap: anywhere; }

/* --- прочее -------------------------------------------------------------------- */

.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
kbd { font: 600 11px/1 var(--mono); padding: 2px 5px; border-radius: 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--surface-2); color: var(--text-2); }

/* переключатель темы: солнце в светлой, луна в тёмной */
.theme-btn .moon { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .moon { display: inline-block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .sun { display: none; }
  :root:not([data-theme="light"]) .theme-btn .moon { display: inline-block; }
}
.theme-btn .icon { transition: rotate .5s var(--ease-spring), transform .3s var(--ease-spring); }
.theme-btn:hover .icon { rotate: 25deg; }

/* --- переходы ------------------------------------------------------------------ */

/* Разделы проявляются анимацией из js/ui.js (reveal): opacity и transform, без
   снимков страницы. View Transitions — только у смены темы: круг из-под кнопки. */
.theme-switching::view-transition-old(root) { animation: none; }
.theme-switching::view-transition-new(root) { animation: theme-reveal .6s var(--ease); }
.theme-switching::view-transition-group(*) { animation: none; }
@keyframes theme-reveal { from { clip-path: circle(0 at var(--tx, 100%) var(--ty, 0)); } to { clip-path: circle(150vmax at var(--tx, 100%) var(--ty, 0)); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .backdrop::before, .backdrop::after, .backdrop i { animation: none; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
