/* Asterion Cluster — стили интерфейса.
   Принципы: цвета — только переменные темы; «стекло» (backdrop-filter) — лишь на плавающих слоях
   (строка меню, док, сайдбар, шапка, всплывашки); анимации — transform/opacity. */

/* ---------- Стили оформления (шаг 19.8) ----------
   Три стиля × две темы. Стандарт интерфейса один (виджеты, окна, док, отступы, скругления), стиль меняет только токены:
   фон стола (`--wall`, `--specks`), поверхности, цвета, шрифты и акцент. На `<html>`: `data-design` — стиль,
   `data-scheme` — итоговая тема (`theme.rs`), `data-palette` — палитра «Космоса». База — «Минимализм», светлая. */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-soft: #f7f7f7;
  --bg-elev: #ffffff;
  --text: #191919;
  --text-2: #6b6b6b;
  --text-3: #a3a3a3;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.15);
  --hover: rgba(0, 0, 0, 0.045);
  --active: rgba(0, 0, 0, 0.075);
  --accent: #191919;
  --accent-soft: rgba(0, 0, 0, 0.06);
  --on-accent: #ffffff;
  --danger: #d93a3f;
  --ok: #2f9a63;
  --warn: #d8901a;
  --code-bg: #f5f5f5;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.14), 0 4px 12px rgba(0, 0, 0, 0.06);
  --glass-bg: rgba(255, 255, 255, 0.86);
  --glass-solid: #ffffff;
  --glass-border: rgba(0, 0, 0, 0.08);
  /* Плитки, виджеты, док: одна поверхность на стиль. */
  --surface: #ffffff;
  --wall: #fafafa;
  --specks: none;
  --wall-1: #ececec;
  --wall-2: #f1f1f1;
  --wall-3: #efefef;
  --wall-base: #fafafa;
  --graph-link: rgba(25, 25, 25, 0.35);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --sidebar-w: 268px;
  --topbar-h: 48px;
  --font: Inter, "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  /* Цифры часов и календарей. */
  --num-font: var(--font);
  --mono: "JetBrains Mono", "Cascadia Code", "SF Mono", Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

:root[data-scheme="dark"] {
  color-scheme: dark;
  --bg: #121212;
  --bg-soft: #171717;
  --bg-elev: #1c1c1c;
  --text: #ededed;
  --text-2: #9a9a9a;
  --text-3: #5e5e5e;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --hover: rgba(255, 255, 255, 0.06);
  --active: rgba(255, 255, 255, 0.1);
  --accent: #ededed;
  --accent-soft: rgba(255, 255, 255, 0.1);
  --on-accent: #111111;
  --danger: #ff6369;
  --ok: #4cc38a;
  --warn: #ffb224;
  --code-bg: #1a1a1a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, 0.6), 0 4px 14px rgba(0, 0, 0, 0.4);
  --glass-bg: rgba(20, 20, 20, 0.86);
  --glass-solid: #161616;
  --glass-border: rgba(255, 255, 255, 0.08);
  --surface: #171717;
  --wall: #0f0f0f;
  --wall-1: #1c1c1c;
  --wall-2: #181818;
  --wall-3: #1a1a1a;
  --wall-base: #0f0f0f;
  --graph-link: rgba(237, 237, 237, 0.35);
}

/* «Космос»: глубокий фон с мягким свечением. Бирюза — по умолчанию, сияние — сиреневая палитра. */
:root[data-design="cosmos"] {
  --font: Onest, Inter, "Segoe UI", system-ui, sans-serif;
  --num-font: Onest, Inter, sans-serif;
  --bg: #fbfcfc;
  --bg-soft: #f2f5f6;
  --bg-elev: #ffffff;
  --text: #2a2e31;
  --text-2: #61686e;
  --text-3: #a7aeb4;
  --border: rgba(40, 60, 80, 0.1);
  --border-strong: rgba(40, 60, 80, 0.18);
  --accent: #2f8f88;
  --accent-soft: rgba(47, 143, 136, 0.12);
  --on-accent: #ffffff;
  --glass-bg: rgba(255, 255, 255, 0.64);
  --glass-solid: #f7f9fa;
  --glass-border: rgba(40, 60, 80, 0.1);
  --surface: rgba(255, 255, 255, 0.66);
  --wall:
    radial-gradient(70vw 80vh at 0% 0%, rgba(160, 222, 195, 0.7), transparent 62%),
    radial-gradient(55vw 60vh at 32% -10%, rgba(214, 236, 170, 0.55), transparent 60%),
    radial-gradient(75vw 88vh at 100% 100%, rgba(170, 200, 245, 0.65), transparent 65%),
    #f8fafa;
  --wall-1: #d6e6be;
  --wall-2: #c4d6ec;
  --wall-3: #d9ecea;
  --wall-base: #f8fafa;
  --graph-link: rgba(47, 143, 136, 0.45);
}
:root[data-design="cosmos"][data-palette="aurora"] {
  --bg: #fbfaff;
  --bg-soft: #f4f1fb;
  --text: #2d2b36;
  --text-2: #625e72;
  --text-3: #aca7bb;
  --border: rgba(90, 70, 140, 0.1);
  --border-strong: rgba(90, 70, 140, 0.18);
  --accent: #7a5cc9;
  --accent-soft: rgba(122, 92, 201, 0.12);
  --glass-border: rgba(90, 70, 140, 0.1);
  --wall:
    radial-gradient(70vw 80vh at 0% 0%, rgba(200, 170, 245, 0.75), transparent 62%),
    radial-gradient(55vw 60vh at 32% -10%, rgba(180, 200, 250, 0.55), transparent 60%),
    radial-gradient(75vw 88vh at 100% 100%, rgba(245, 190, 228, 0.65), transparent 65%),
    #faf9fd;
  --wall-1: #d6c2f6;
  --wall-2: #f4d0ec;
  --wall-3: #c8d4f8;
  --wall-base: #faf9fd;
  --graph-link: rgba(122, 92, 201, 0.45);
}
:root[data-design="cosmos"][data-scheme="dark"] {
  --bg: #0b0f14;
  --bg-soft: #10151c;
  --bg-elev: #151b24;
  --text: #eef2f5;
  --text-2: #9aa6b2;
  --text-3: #58636f;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --accent: #5cc8c0;
  --accent-soft: rgba(92, 200, 192, 0.16);
  --on-accent: #061413;
  --code-bg: #121820;
  --glass-bg: rgba(10, 20, 24, 0.58);
  --glass-solid: #121820;
  --glass-border: rgba(255, 255, 255, 0.08);
  --surface: rgba(14, 28, 34, 0.5);
  --wall:
    radial-gradient(70vw 80vh at 0% 0%, rgba(40, 200, 150, 0.42), transparent 62%),
    radial-gradient(55vw 60vh at 30% -10%, rgba(30, 150, 170, 0.3), transparent 60%),
    radial-gradient(75vw 88vh at 100% 100%, rgba(50, 90, 190, 0.38), transparent 65%),
    radial-gradient(47vw 52vh at 100% 15%, rgba(20, 110, 120, 0.25), transparent 65%),
    linear-gradient(180deg, #06090d, #04060a);
  --wall-1: #12403d;
  --wall-2: #1b2c55;
  --wall-3: #0f2a33;
  --wall-base: #05070a;
  --graph-link: rgba(92, 200, 192, 0.5);
}
:root[data-design="cosmos"][data-palette="aurora"][data-scheme="dark"] {
  --bg: #0e0c16;
  --bg-soft: #13101d;
  --bg-elev: #191526;
  --text: #f3f1fb;
  --text-2: #a7a1bd;
  --text-3: #5f5975;
  --accent: #a78bfa;
  --accent-soft: rgba(167, 139, 250, 0.16);
  --on-accent: #140c26;
  --code-bg: #15121f;
  --glass-bg: rgba(20, 14, 32, 0.58);
  --glass-solid: #15121f;
  --surface: rgba(28, 20, 44, 0.5);
  --wall:
    radial-gradient(70vw 80vh at 0% 0%, rgba(170, 100, 235, 0.46), transparent 62%),
    radial-gradient(55vw 60vh at 30% -10%, rgba(100, 120, 240, 0.32), transparent 60%),
    radial-gradient(75vw 88vh at 100% 100%, rgba(30, 130, 170, 0.36), transparent 65%),
    radial-gradient(47vw 52vh at 100% 15%, rgba(120, 60, 170, 0.22), transparent 65%),
    linear-gradient(180deg, #08060e, #05040a);
  --wall-1: #3b2266;
  --wall-2: #173a55;
  --wall-3: #2a1d4a;
  --wall-base: #07060c;
  --graph-link: rgba(167, 139, 250, 0.5);
}

/* «Кутюр»: бордо (#730c1e, #480415, #210207, #140f17) и золото, антиква в цифрах, редкие золотые вкрапления. */
:root[data-design="couture"] {
  --num-font: "Cormorant Garamond", Georgia, serif;
  --bg: #fbf7f4;
  --bg-soft: #f4ece8;
  --bg-elev: #fffcfa;
  --text: #210207;
  --text-2: #6e5258;
  --text-3: #b09c9d;
  --border: rgba(115, 12, 30, 0.12);
  --border-strong: rgba(115, 12, 30, 0.22);
  --hover: rgba(115, 12, 30, 0.05);
  --active: rgba(115, 12, 30, 0.09);
  --accent: #730c1e;
  --accent-soft: rgba(115, 12, 30, 0.09);
  --on-accent: #f7ead8;
  --glass-bg: rgba(255, 252, 250, 0.74);
  --glass-solid: #fbf7f4;
  --glass-border: rgba(115, 12, 30, 0.12);
  --surface: rgba(255, 252, 250, 0.8);
  --wall:
    radial-gradient(70vw 75vh at 0% 0%, rgba(115, 12, 30, 0.1), transparent 70%),
    radial-gradient(65vw 75vh at 100% 100%, rgba(72, 4, 21, 0.08), transparent 70%),
    #f7f1ee;
  --wall-1: #e8c9cc;
  --wall-2: #ead9c4;
  --wall-3: #efe1dc;
  --wall-base: #f7f1ee;
  --graph-link: rgba(115, 12, 30, 0.4);
}
:root[data-design="couture"][data-scheme="dark"] {
  --bg: #140f17;
  --bg-soft: #1a1118;
  --bg-elev: #20141b;
  --text: #f4ebe4;
  --text-2: #b8a7a3;
  --text-3: #6f5f60;
  --border: rgba(214, 178, 104, 0.15);
  --border-strong: rgba(214, 178, 104, 0.26);
  --hover: rgba(214, 178, 104, 0.07);
  --active: rgba(214, 178, 104, 0.12);
  --accent: #d6b268;
  --accent-soft: rgba(214, 178, 104, 0.14);
  --on-accent: #210207;
  --code-bg: #1c1218;
  --glass-bg: rgba(33, 2, 7, 0.58);
  --glass-solid: #1c0b11;
  --glass-border: rgba(214, 178, 104, 0.15);
  --surface: rgba(33, 2, 7, 0.52);
  --wall:
    radial-gradient(85vw 95vh at 0% 0%, #730c1e 0%, rgba(115, 12, 30, 0) 70%),
    radial-gradient(70vw 90vh at 100% 100%, #210207 0%, rgba(33, 2, 7, 0) 70%),
    linear-gradient(160deg, #480415 0%, #210207 55%, #140f17 100%);
  --wall-1: #730c1e;
  --wall-2: #480415;
  --wall-3: #210207;
  --wall-base: #140f17;
  --graph-link: rgba(214, 178, 104, 0.45);
}
/* Золотые вкрапления — редкие точки поверх фона стола. */
:root[data-design="couture"] {
  --specks:
    radial-gradient(circle at 12% 18%, rgba(214, 178, 104, 0.9) 0 1px, transparent 1.6px),
    radial-gradient(circle at 63% 9%, rgba(214, 178, 104, 0.7) 0 1px, transparent 1.6px),
    radial-gradient(circle at 81% 42%, rgba(214, 178, 104, 0.8) 0 1.2px, transparent 1.8px),
    radial-gradient(circle at 34% 71%, rgba(214, 178, 104, 0.6) 0 1px, transparent 1.6px),
    radial-gradient(circle at 92% 83%, rgba(214, 178, 104, 0.7) 0 1px, transparent 1.6px),
    radial-gradient(circle at 5% 88%, rgba(214, 178, 104, 0.6) 0 1px, transparent 1.6px),
    radial-gradient(circle at 48% 46%, rgba(214, 178, 104, 0.5) 0 0.8px, transparent 1.4px),
    radial-gradient(circle at 24% 38%, rgba(214, 178, 104, 0.5) 0 0.8px, transparent 1.4px),
    radial-gradient(circle at 72% 64%, rgba(214, 178, 104, 0.55) 0 1px, transparent 1.6px),
    radial-gradient(circle at 56% 90%, rgba(214, 178, 104, 0.5) 0 0.8px, transparent 1.4px);
}

/* ---------- База ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

button:disabled {
  cursor: default;
  opacity: 0.45;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection {
  background: var(--accent-soft);
}

.icon {
  display: inline-flex;
  flex: none;
}

.muted { color: var(--text-2); }
.small { font-size: 12px; }
.spacer { flex: 1; }
.hint { margin: 4px 2px; }

kbd {
  font: 11px var(--font);
  color: var(--text-3);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0 5px;
}

/* ---------- Стекло ---------- */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(170%);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: var(--glass-solid); }
}

@media (prefers-reduced-transparency: reduce) {
  .glass {
    background: var(--glass-solid);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* ---------- Кнопки и поля ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius);
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s, transform 0.12s var(--ease);
}

.btn:active:not(:disabled) { transform: scale(0.97); }
.btn.small { height: 26px; padding: 0 8px; font-size: 12px; }

.btn.primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { color: var(--text-2); }

.btn.ghost:hover:not(:disabled) {
  background: var(--hover);
  color: var(--text);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: var(--radius);
  color: var(--text-2);
  transition: background 0.12s, color 0.12s;
}

.icon-btn.tiny { width: 22px; height: 22px; border-radius: var(--radius-sm); }

.icon-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.danger:hover:not(:disabled) { color: var(--danger) !important; }

input[type="text"],
input[type="url"],
input[type="password"] {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-elev);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}

input[type="text"]:focus,
input[type="url"]:focus,
input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- Цвета плиток и папок ---------- */
.t-blue   { --tile-a: #4f8cff; --tile-b: #2f5bf6; }
.t-violet { --tile-a: #a274ff; --tile-b: #6a42f0; }
.t-green  { --tile-a: #3fcf8e; --tile-b: #1f9d6b; }
.t-orange { --tile-a: #ffaf55; --tile-b: #f2702a; }
.t-pink   { --tile-a: #ff7ab3; --tile-b: #e5407e; }
.t-teal   { --tile-a: #3cc7d6; --tile-b: #1590a8; }

.c-blue   { --folder: #4f8cff; }
.c-violet { --folder: #9567ff; }
.c-green  { --folder: #34c27f; }
.c-orange { --folder: #ff9a3d; }
.c-pink   { --folder: #ff5f9e; }
.c-gray   { --folder: #8e8e98; }

/* ---------- Рабочий стол ---------- */
.desktop {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Фон стола — из стиля: статичные градиенты и вкрапления, без анимаций и картинок. */
  background: var(--specks), var(--wall);
}

.menubar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 36px;
  padding: 0 14px;
  border-bottom: 1px solid var(--glass-border);
  font-size: 13px;
}

.menubar-logo {
  font-weight: 800;
  letter-spacing: -0.02em;
}

.menubar-title { font-weight: 600; }
.bell { position: relative; display: inline-flex; }
.bell-count {
  position: absolute;
  top: -3px;
  right: -4px;
  min-width: 15px;
  padding: 0 3px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
}
.bell-backdrop { position: fixed; inset: 0; z-index: 59; }
.bell-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: -8px;
  z-index: 60;
  display: flex;
  width: min(340px, calc(100vw - 24px));
  max-height: min(460px, 70vh);
  flex-direction: column;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  animation: pop 0.12s var(--ease);
}
.bell-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.bell-all { color: var(--accent); font-size: 12px; }
.bell-empty { margin: 0; padding: 18px 14px; }
.bell-list { overflow-y: auto; padding: 4px; }
.bell-item {
  display: flex;
  width: 100%;
  flex-direction: column;
  gap: 1px;
  padding: 8px 10px;
  border-radius: 9px;
  font-weight: 400;
  text-align: left;
}
.bell-item span { color: var(--text-2); font-size: 13px; }
.bell-item small { font-size: 11px; }
.bell-item:hover { background: var(--hover); }
.bell-item.unread { background: var(--accent-soft); }
.menubar-clock { color: var(--text-2); font-variant-numeric: tabular-nums; }
.menubar .theme-switch { margin: 0; }

.desktop-main {
  flex: 1;
  padding: 36px 40px 140px;
}

.desktop-grid {
  grid-template-columns: repeat(auto-fill, 112px);
  gap: 22px 18px;
}

.desktop-hint {
  margin-top: 24px;
  color: var(--text-2);
}

.desk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 18px 14px;
  min-height: 116px;
  padding: 10px;
  margin: 0 -10px;
  border: 1.5px dashed transparent;
  border-radius: var(--radius-lg);
  transition: border-color 0.15s, background 0.15s;
}

.desk-grid.drop-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.desk-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 4px;
  border-radius: var(--radius);
  text-align: center;
  contain: layout paint;
  transition: background 0.12s;
}

.desk-item:hover { background: var(--hover); }
.desk-item.dragging { opacity: 0.4; }
.desk-item.drop-over { background: var(--accent-soft); }

.desk-item:hover .ws-tile,
.desk-item:hover .folder-tile,
.desk-item:hover .file-tile {
  transform: translateY(-2px) scale(1.03);
}

.desk-label {
  max-width: 100%;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.desktop .desk-label { text-shadow: 0 1px 2px color-mix(in srgb, var(--bg) 70%, transparent); }
.desk-meta { font-size: 11px; color: var(--text-3); }

/* Плитка пространства — «иконка приложения». */
.ws-tile {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border-radius: 18px;
  background: linear-gradient(145deg, var(--tile-a, #6b7bff), var(--tile-b, #3b4ce0));
  color: #fff;
  font-size: 30px;
  font-weight: 700;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--tile-b, #3b4ce0) 35%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform 0.18s var(--ease);
}

.ws-tile.new {
  background: var(--glass-bg);
  color: var(--text-2);
  border: 1.5px dashed var(--border-strong);
  box-shadow: none;
}

.ws-tile.big { width: 56px; height: 56px; border-radius: 15px; font-size: 26px; flex: none; }

/* Папка: «язычок» + корпус цвета группы. */
.folder-tile {
  position: relative;
  width: 76px;
  height: 60px;
  margin-top: 6px;
  transition: transform 0.18s var(--ease);
}

.folder-tab {
  position: absolute;
  left: 4px;
  top: -6px;
  width: 32px;
  height: 14px;
  border-radius: 6px 6px 0 0;
  background: color-mix(in srgb, var(--folder) 78%, #000);
}

.folder-body {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 6px 12px 12px 12px;
  background: linear-gradient(170deg, color-mix(in srgb, var(--folder) 82%, #fff), var(--folder));
  box-shadow: 0 6px 16px color-mix(in srgb, var(--folder) 35%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  font-size: 24px;
}

.folder-tile.big { width: 64px; height: 50px; flex: none; }

.file-tile {
  display: grid;
  place-items: center;
  width: 56px;
  height: 68px;
  border-radius: 6px 16px 8px 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  color: var(--text-3);
  transition: transform 0.18s var(--ease);
}

/* Док. */
.dock {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
  padding: 8px 10px;
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  overflow-x: auto;
}

.dock-item {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--tile-a, #6b7bff), var(--tile-b, #3b4ce0));
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  transition: transform 0.18s var(--ease);
}

.dock-item:hover { transform: translateY(-4px) scale(1.12); }
.dock-item.plain { background: var(--hover); color: var(--text-2); }
.dock-sep { width: 1px; height: 32px; background: var(--border-strong); margin: 0 2px; }

/* Контекстное меню и модальные окна. */
.context-menu {
  position: fixed;
  z-index: 60;
  min-width: 190px;
  padding: 5px;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  animation: pop 0.12s var(--ease);
}

.menu-sep { height: 1px; margin: 4px 6px; background: var(--border); }

.popover-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  border-radius: 7px;
  text-align: left;
}

.popover-item:hover { background: var(--accent); color: var(--on-accent); }
.popover-item.danger:hover { background: var(--danger); color: #fff !important; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.25);
  animation: fade 0.15s;
}

.modal {
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  animation: pop 0.16s var(--ease);
}

.modal h2 { margin: 0 0 14px; font-size: 18px; }
.modal-row { display: flex; gap: 8px; }
.emoji-input { flex: 0 0 52px !important; text-align: center; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

@keyframes pop { from { opacity: 0; transform: scale(0.96); } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Прочее ---------- */
.welcome {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 16px;
}

.welcome-card {
  width: min(440px, 100%);
  padding: 36px 32px;
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  text-align: center;
}

.loader {
  width: 22px;
  height: 22px;
  margin: 48px auto;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 16px;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transform: translateX(-50%);
  animation: toast-in 0.2s var(--ease);
}

.toast.error { color: var(--danger); }

@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

.mobile-only,
.sidebar-backdrop { display: none; }

/* ---------- Связь с сервером ---------- */
.conn-banner {
  position: fixed;
  top: 12px;
  left: 50%;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(560px, calc(100vw - 24px));
  padding: 10px 12px 10px 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--glass-border));
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  transform: translateX(-50%);
  animation: toast-in 0.2s var(--ease);
}

.conn-dot {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 20%, transparent);
  animation: pulse 1.6s infinite;
}

.conn-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}

/* ---------- Палитра поиска (Ctrl+K) ---------- */
.palette-backdrop {
  position: fixed;
  inset: 0;
  z-index: 85;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh 16px 16px;
  background: rgba(0, 0, 0, 0.22);
  animation: fade 0.12s;
}

.palette {
  width: min(680px, 100%);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop 0.14s var(--ease);
}

.palette-input {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
}

.palette-input input[type="text"] {
  height: 30px;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none !important;
  font-size: 16px;
  color: var(--text);
}

.spinner {
  width: 14px;
  height: 14px;
  flex: none;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.scope-switch {
  display: flex;
  flex: none;
  padding: 2px;
  border-radius: 8px;
  background: var(--hover);
  font-size: 12px;
}

.scope-switch button {
  padding: 3px 9px;
  border-radius: 6px;
  color: var(--text-2);
  white-space: nowrap;
}

.scope-switch button.active {
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.palette-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  overscroll-behavior: contain;
}

.palette-section {
  padding: 8px 10px 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
}

.palette-empty {
  padding: 18px 10px;
  text-align: center;
  color: var(--text-3);
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 7px 10px;
  border-radius: 9px;
  text-align: left;
}

.palette-item.active { background: var(--accent-soft); }

.palette-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 7px;
  background: var(--hover);
  color: var(--text-2);
}

.palette-emoji { font-size: 15px; }

.palette-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.palette-title {
  flex: 1;
  min-width: 0;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette-snippet {
  font-size: 12px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette-item mark {
  padding: 0 1px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--warn) 35%, transparent);
  color: inherit;
}

.palette-badge {
  flex: none;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--hover);
  font-size: 11px;
  color: var(--text-2);
}

.palette-path {
  flex: none;
  max-width: 34%;
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette-foot {
  display: flex;
  gap: 14px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-3);
}

.menubar-btn {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  color: var(--text-2);
}

.menubar-btn:hover { background: var(--hover); color: var(--text); }

@media (max-width: 820px) {
  .palette-path, .palette-foot { display: none; }
  .scope-switch button { padding: 3px 6px; }
}

/* ---------- Значок страницы (небесное тело) ---------- */
.body-picker {
  position: relative;
  display: inline-block;
  margin-bottom: 6px;
}

.page-emoji {
  display: block;
  padding: 2px 4px;
  border-radius: 12px;
  font-size: 52px;
  line-height: 1.1;
  transition: background 0.12s;
}

.page-emoji:hover:not(:disabled) { background: var(--hover); }

.add-icon {
  opacity: 0;
  transition: opacity 0.12s;
}

.page-head:hover .add-icon,
.add-icon:focus-visible { opacity: 1; }

.body-grid {
  right: auto;
  width: 292px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  padding: 8px;
}

.body-cell {
  display: grid;
  place-items: center;
  height: 40px;
  border-radius: 9px;
  font-size: 22px;
  transition: background 0.1s, transform 0.1s;
}

.body-cell:hover { background: var(--hover); transform: scale(1.12); }
.body-cell.active { background: var(--accent-soft); }
.body-clear { grid-column: 1 / -1; justify-content: center; margin-top: 4px; }

.legend-hint { color: var(--text-3); }

/* ---------- «Недавнее» в доке ---------- */
.dock-item.recent-app { --tile-a: #ffb86b; --tile-b: #f2702a; }
.dock-item.recent-app.open { transform: translateY(-4px); }
.stack-veil { position: fixed; inset: 0; z-index: 25; }

.dock-stack {
  position: fixed;
  left: 50%;
  bottom: 88px;
  z-index: 26;
  width: min(420px, calc(100vw - 32px));
  max-height: min(70vh, 560px);
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  transform: translateX(-50%);
  transform-origin: bottom center;
  animation: stack-up 0.18s var(--ease);
}

@keyframes stack-up { from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.97); } }

.stack-list { display: flex; flex-direction: column; gap: 1px; margin-bottom: 8px; }

.stack-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
}

.stack-row:hover { background: var(--hover); }
.stack-icon { width: 22px; text-align: center; font-size: 16px; }
.stack-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }

/* ---------- Профиль и оформление (шаг 7.9) ---------- */

/* Акцентный цвет: одна переменная-основа, светлая/тёмная тема берут её как есть. */

/* Размер текста статьи и ширина колонки. */
.editor .ProseMirror,
.doc { font-size: var(--doc-font, 16px); }
:root[data-width="narrow"] .content:not(.wide) { max-width: 720px; }
:root[data-width="wide"] .content:not(.wide) { max-width: 1080px; }

/* Компактная плотность: меньше отступы в сайдбаре, дереве и контенте. */
:root[data-density="compact"] {
  --sidebar-w: 240px;
  --topbar-h: 42px;
}
:root[data-density="compact"] .content { padding-top: 22px; padding-bottom: 80px; }
:root[data-density="compact"] :is(.tree-row, .nav-item) { min-height: 26px; padding-top: 2px; padding-bottom: 2px; }
:root[data-density="compact"] .editor .ProseMirror > * + * { margin-top: 0.4em; }
:root[data-density="compact"] .desk-grid:not(.desktop-grid) { gap: 10px; }

/* Без анимаций: переходы и всплытия выключены (орбиты останавливает сам граф). */
:root[data-motion="off"] *,
:root[data-motion="off"] *::before,
:root[data-motion="off"] *::after {
  transition: none !important;
  animation: none !important;
}

/* «Минимализм»: плоские папки и плитки пространств, спокойный граф, сплошные панели без стекла. */
:root:not([data-design="cosmos"]):not([data-design="couture"]) .shell { background: var(--bg); }
:root:not([data-design="cosmos"]):not([data-design="couture"]) .ws-tile:not(.new) {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}
:root:not([data-design="cosmos"]):not([data-design="couture"]) .folder-body {
  background: color-mix(in srgb, var(--folder) 22%, var(--bg-elev));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--folder) 45%, transparent);
}
:root:not([data-design="cosmos"]):not([data-design="couture"]) .folder-tab { background: color-mix(in srgb, var(--folder) 40%, var(--bg-elev)); }
:root:not([data-design="cosmos"]):not([data-design="couture"]) .desk-item:hover :is(.ws-tile, .folder-tile) { transform: none; }
:root:not([data-design="cosmos"]):not([data-design="couture"]) :is(.graph-view, .local-graph, .graph-block-body) { background: var(--bg-soft); }
:root:not([data-design="cosmos"]):not([data-design="couture"]) .glass { backdrop-filter: none; background: var(--glass-solid); }
:root:not([data-design="cosmos"]):not([data-design="couture"]) .body-img { filter: saturate(0.75); }

/* Значок страницы. */
.body-img { display: inline-block; flex: none; vertical-align: middle; object-fit: contain; }
.page-glyph { display: inline-grid; place-items: center; line-height: 1; }
.page-emoji .body-img { display: block; }
.body-grid {
  width: 340px;
  max-height: 420px;
  overflow-y: auto;
  grid-template-columns: repeat(7, 1fr);
}
.body-section {
  grid-column: 1 / -1;
  margin: 6px 4px 2px;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.body-section:first-child { margin-top: 0; }
.body-cell { height: 42px; }

/* Аватар. */
.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 70%, #fff), var(--accent));
  color: #fff;
  font-weight: 700;
  line-height: 1;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.menubar-profile { display: grid; place-items: center; border-radius: 50%; }
.menubar-profile:hover { box-shadow: 0 0 0 2px var(--accent-soft); }
.profile-link span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Окно профиля. */
.profile-layer { position: fixed; inset: 36px 0 0; z-index: 15; display: grid; place-items: center; }
.profile-layer .profile-window { pointer-events: auto; }
.profile-window {
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.profile-who { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.profile-name {
  padding: 2px 4px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: none;
  color: var(--text);
  font: 600 20px var(--font);
  outline: none;
}
.profile-name:hover { border-color: var(--border); }
.profile-name:focus { border-color: var(--accent); }
.profile-avatar-actions { display: flex; gap: 6px; }
.profile-body { overflow-y: auto; padding: 4px 20px 20px; }
.profile-section { padding: 14px 0; border-bottom: 1px solid var(--border); }
.profile-section:last-child { border-bottom: 0; }
.profile-section h3 { margin: 0 0 10px; font-size: 13px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; }
.profile-row { display: flex; align-items: center; gap: 12px; margin: 8px 0; flex-wrap: wrap; }
.profile-key { width: 170px; color: var(--text-2); font-size: 13px; }
.profile-check { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 13.5px; }
.profile-check input { accent-color: var(--accent); }
.profile-row input[type="range"] { accent-color: var(--accent); width: 180px; }

/* Сегментный переключатель. */
.pseg {
  display: inline-flex;
  padding: 2px;
  border-radius: 9px;
  background: var(--hover);
  flex-wrap: wrap;
}
.pseg button {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 7px;
  color: var(--text-2);
  font-size: 13px;
}
.pseg button.active { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-sm); }


/* Карточки оформления с мини-превью. */
.design-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 8px; }
.design-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  text-align: left;
  cursor: pointer;
}
.design-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.design-preview {
  position: relative;
  width: 100%;
  height: 54px;
  margin-bottom: 4px;
  overflow: hidden;
  border-radius: 8px;
}
.design-preview i { position: absolute; top: 14px; width: 22px; height: 22px; border-radius: 7px; }
.design-preview i:nth-child(1) { left: 12px; }
.design-preview i:nth-child(2) { left: 40px; }
.design-preview i:nth-child(3) { left: 68px; width: 40px; }
.d-minimal .design-preview { background: #fafafa; border: 1px solid #e6e6e6; }
.d-minimal .design-preview i { background: #fff; border: 1px solid #d9d9d9; }
.d-minimal .design-preview i:nth-child(1) { background: #191919; border-color: #191919; }
.d-cosmos .design-preview { background: radial-gradient(90px 60px at 0% 0%, rgba(46, 170, 140, 0.35), transparent 70%), radial-gradient(90px 60px at 100% 100%, rgba(40, 80, 150, 0.45), transparent 70%), #07090d; }
.d-cosmos .design-preview i { background: rgba(18, 22, 30, 0.7); border: 1px solid rgba(255, 255, 255, 0.1); }
.d-cosmos .design-preview i:nth-child(1) { background: #5cc8c0; border-color: transparent; }
.d-couture .design-preview { background: radial-gradient(120px 70px at 0% 0%, #730c1e, transparent 75%), linear-gradient(160deg, #480415, #210207 60%, #140f17); }
.d-couture .design-preview i { background: rgba(33, 2, 7, 0.6); border: 1px solid rgba(214, 178, 104, 0.25); }
.d-couture .design-preview i:nth-child(1) { background: #d6b268; border-color: transparent; }

@media (max-width: 640px) {
  .profile-key { width: 100%; }
  .design-cards { grid-template-columns: 1fr; }
}

/* Аватар в пункте сайдбара не растягивается вместе с подписью. */
.nav-item .avatar { flex: none; }

/* ---------- Свои окна ввода и подтверждения (вместо window.prompt/confirm) ---------- */
.dialog-layer { z-index: 90; }
.dialog-input {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  outline: none;
}
.dialog-input:focus { border-color: var(--accent); }
.dialog-text { margin: 0; line-height: 1.5; }
.btn.danger-solid { background: var(--danger); color: #fff; }
.btn.danger-solid:hover { filter: brightness(1.08); }
.icon-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  margin: 8px 0 10px;
}
.icon-grid.compact { margin-top: 0; }
.icon-cell {
  display: grid;
  place-items: center;
  height: 38px;
  border-radius: 9px;
  font-size: 20px;
  transition: background-color 0.1s, transform 0.1s;
}
.icon-cell:hover { background: var(--hover); transform: scale(1.1); }
.icon-cell.active { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.modal-row .emoji-input { width: 64px; flex: none; text-align: center; }
.modal-row .muted { align-self: center; }

/* Подсказка о видах связей в панели «Связи». */
.rel-help { margin: 0; padding: 8px 12px; border-bottom: 1px solid var(--border); color: var(--text-2); font-size: 12px; line-height: 1.45; }

/* Карточка связей тела на графе (плавающий слой поверх холста). */
.graph-card {
  position: absolute;
  z-index: 3;
  max-width: 280px;
  padding: 8px 10px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px) saturate(1.5);
  box-shadow: var(--shadow);
  font-size: 12px;
  line-height: 1.45;
  pointer-events: none;
}
.graph-card[hidden] { display: none; }
.graph-card-title { font-size: 13px; font-weight: 600; }
.graph-card-sub { margin-bottom: 4px; color: var(--text-2); }
.graph-card-row { display: flex; gap: 6px; }
.graph-card-row b { flex: none; width: 14px; color: var(--accent); text-align: center; }
:root:not([data-design="cosmos"]):not([data-design="couture"]) .graph-card { backdrop-filter: none; background: var(--glass-solid); }

/* ---------- Закрепления и файлы без модуля ---------- */
.desk-item.unavailable { opacity: 0.55; }
.desktop-main.drop-over { outline: 2px dashed var(--accent); outline-offset: -8px; }
.file-off { color: var(--text-3); }
.file-off-label { font-size: 13px; color: var(--text-3); }
.file-list-plain { max-height: 180px; margin: 6px 0 12px; padding-left: 18px; overflow: auto; font-size: 13px; }

/* ---------- Внешние сервисы ---------- */
.app-emoji { line-height: 1; }
.service-main { position: fixed; inset: 44px 12px 92px; display: grid; place-items: center; }
.service-frame { width: 100%; height: 100%; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.service-note { color: var(--text-2); text-align: center; }
.service-note .btn { margin-top: 10px; }
.service-icon { font-size: 20px; }

/* ---------- Вход и пользователи ---------- */
.auth-screen { display: grid; min-height: 100vh; padding: 16px; place-items: center; background: var(--bg); }
.auth-card { display: flex; width: min(340px, 100%); flex-direction: column; gap: 10px; padding: 24px; border: 1px solid var(--border); border-radius: 16px; }
.auth-card h1 { margin: 0 0 6px; font-size: 22px; }
.logo { display: inline-flex; align-items: center; gap: 0.35em; }
.logo-mark { width: 1.3em; height: 1.3em; flex: none; }
.logo-orbit { fill: none; stroke: currentColor; stroke-width: 1.1; opacity: 0.75; }
.logo-body { fill: currentColor; }
.logo-core { fill: #f5b942; }
.auth-form { display: flex; flex-direction: column; gap: 10px; margin: 8px 0; max-width: 340px; }
.auth-card input, .auth-form input, .admin-field input, .admin-field select {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text);
}
.auth-card .auth-form { margin: 0; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.auth-links:empty { display: none; }
.auth-server { display: flex; justify-content: space-between; gap: 12px; margin: 4px 0 0; overflow-wrap: anywhere; }
.auth-error { margin: 0; color: var(--danger); font-size: 13px; }

/* ---------- Администрирование ---------- */
.admin-window { width: min(760px, calc(100vw - 32px)); height: min(680px, calc(100vh - 120px)); }
.admin-title { margin: 0; font-size: 17px; }
.admin-tabs { align-self: flex-start; margin: 0 20px 8px; }
.admin-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0; }
.admin-back { margin: 10px 0 2px; }
.admin-subtitle { margin: 18px 0 2px; font-size: 13px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; }
.admin-form { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.admin-form h3 { margin: 6px 0 0; font-size: 15px; }
.admin-form .profile-check { margin: 0; }
.admin-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.admin-field input, .admin-field select { width: 100%; box-sizing: border-box; }
.admin-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.admin-grant { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; margin: 12px 0; }
.danger-text { color: var(--danger); }
/* Кнопки в одном столбце у правого края, какой бы длины ни было название. */
.admin-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.admin-row-main { display: flex; grid-column: 2; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.admin-row-side { display: flex; grid-column: 3; gap: 6px; }
@media (max-width: 560px) {
  .admin-row { grid-template-columns: auto minmax(0, 1fr); }
  .admin-row-side { grid-column: 2; justify-content: flex-end; }
}
/* ---------- Магазин ---------- */
.store-desk { height: 100vh; }
.store-main { flex: 1; min-height: 0; overflow-y: auto; padding: 28px max(24px, calc(50vw - 560px)) 130px; }
.store-empty { margin: 48px 0; color: var(--text-2); text-align: center; }
.store-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 16px; }
.store-hero h1 { margin: 0; font-size: 30px; font-weight: 750; letter-spacing: -0.02em; }
.store-hero p { margin: 4px 0 0; }
.store-search { display: flex; align-items: center; gap: 8px; width: 260px; height: 38px; padding: 0 12px; border: 1px solid var(--glass-border); border-radius: 11px; color: var(--text-2); }
.store-search input { width: 100%; border: 0; outline: 0; background: none; color: var(--text); font: inherit; }
.store-categories { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.store-categories button { padding: 5px 13px; border-radius: 999px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.store-categories button:hover { background: var(--hover); }
.store-categories button.active { background: var(--accent); color: var(--on-accent); }
.store-section { margin: 22px 0 10px; font-size: 17px; font-weight: 650; }
.store-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.store-card { display: flex; overflow: hidden; flex-direction: column; border: 1px solid var(--glass-border); border-radius: 16px; color: inherit; box-shadow: var(--shadow-sm); transition: transform 0.14s var(--ease), box-shadow 0.14s; }
.store-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.store-preview { display: block; aspect-ratio: 16 / 9; overflow: hidden; background: linear-gradient(135deg, var(--wall-1), var(--wall-2)); }
.store-preview img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top left; }
.store-card-body { display: flex; gap: 11px; padding: 12px 14px 8px; }
.store-card-text { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.store-card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding: 0 14px 12px; }
.store-state { padding: 3px 11px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; }
.store-icon { display: grid; width: 44px; height: 44px; flex: none; place-items: center; border-radius: 11px; background: linear-gradient(145deg, var(--tile-a), var(--tile-b)); font-size: 23px; box-shadow: var(--shadow-sm); }
.store-icon.big { width: 76px; height: 76px; border-radius: 18px; font-size: 40px; }
.store-back { display: inline-block; margin-bottom: 10px; color: var(--text-2); font-size: 13px; }
.store-head { display: flex; align-items: center; gap: 16px; padding: 16px 18px; border: 1px solid var(--glass-border); border-radius: 18px; }
.store-head-text { min-width: 0; flex: 1; }
.store-head h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.store-head p { margin: 3px 0 0; }
.store-actions { display: flex; flex: none; gap: 8px; }
.store-busy { margin: 10px 4px 0; }
.store-page { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; margin-top: 14px; align-items: start; }
.store-column { display: flex; min-width: 0; flex-direction: column; gap: 14px; }
.store-gallery { overflow: hidden; padding: 10px; border: 1px solid var(--glass-border); border-radius: 16px; }
.store-shot { display: block; width: 100%; border-radius: 9px; }
.store-thumbs { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; }
.store-thumbs button { width: 112px; flex: none; overflow: hidden; padding: 0; border: 2px solid transparent; border-radius: 8px; opacity: 0.7; }
.store-thumbs button.active { border-color: var(--accent); opacity: 1; }
.store-thumbs img { display: block; width: 100%; }
.store-block { padding: 14px 16px; border: 1px solid var(--glass-border); border-radius: 16px; }
.store-block h2 { margin: 0 0 8px; font-size: 15px; font-weight: 650; }
.store-block p { margin: 0; line-height: 1.55; }
.store-features { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 18px; margin: 0; padding: 0 0 0 18px; }
.store-rights { display: flex; margin: 0; padding: 0; flex-direction: column; gap: 10px; list-style: none; }
.store-rights li { display: flex; gap: 10px; color: var(--accent); }
.store-rights span { display: flex; min-width: 0; flex-direction: column; color: var(--text); font-size: 13px; }
.store-rights small { font-size: 12px; }
.store-facts { margin: 0; font-size: 13px; }
.store-facts div { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.store-facts div:last-child { border-bottom: 0; }
.store-facts dt { color: var(--text-2); }
.store-facts dd { margin: 0; font-weight: 600; }
.store-manage { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.store-manage .danger { color: var(--danger); }

@media (max-width: 860px) {
  .store-main { padding: 16px 16px 120px; }
  .store-hero { align-items: stretch; flex-direction: column; gap: 12px; }
  .store-search { width: 100%; }
  .store-page { grid-template-columns: 1fr; }
  .store-features { grid-template-columns: 1fr; }
  .store-head { flex-wrap: wrap; }
  .store-actions { width: 100%; }
}
.login-slogan { margin: -0.4rem 0 1rem; text-align: center; font-size: 0.85rem; opacity: 0.7; }

/* Виджеты стола (шаг 19.5): клетка сетки 112×120, виджет занимает несколько клеток.
   Свободная сетка (19.7): колонки, ряды и место элемента задаёт оболочка, шаг клетки — константы в `views/desktop.rs`. */
.desk-grid.desktop-grid { grid-auto-rows: 120px; gap: 22px 18px; padding: 0; margin: 0; border: 0; min-height: 0; }
.desk-ghost { border: 2px dashed var(--accent); border-radius: 20px; background: var(--accent-soft); pointer-events: none; }
.desk-ghost.bad { border-color: var(--danger, #d33); background: color-mix(in srgb, var(--danger, #d33) 12%, transparent); }
.desk-widget {
  --cols: 1;
  --rows: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  grid-column: span var(--cols);
  grid-row: span var(--rows);
  overflow: hidden;
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  box-shadow: var(--shadow-sm, 0 4px 14px rgba(0, 0, 0, 0.08));
  contain: layout paint;
}
.desk-widget.w-2x1 { --cols: 2; }
.desk-widget.w-2x2 { --cols: 2; --rows: 2; }
.desk-widget.w-4x2 { --cols: 4; --rows: 2; }
.desk-widget.dragging { opacity: 0.4; }
.desk-widget.unavailable { opacity: 0.6; }
.widget-grip {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 4px 0 12px;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  cursor: grab;
  opacity: 0;
  transition: opacity 0.15s;
}
.desk-widget:hover .widget-grip, .widget-grip:focus-within { opacity: 1; background: linear-gradient(var(--glass-bg), transparent); }
.widget-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.widget-more { display: grid; width: 22px; height: 22px; padding: 0; place-items: center; border: 0; border-radius: 6px; background: none; color: inherit; cursor: pointer; }
.widget-more:hover { background: var(--hover); color: var(--text); }
.widget-body { flex: 1; min-height: 0; }
.widget-frame { display: block; width: 100%; height: 100%; border: 0; background: transparent; }
/* Без `body:has(...)`: он пересчитывает стили всего документа на каждый шаг переноса. */
.desktop-grid.dragging-on .widget-frame { pointer-events: none; }
.widget-stub { display: flex; height: 100%; padding: 12px; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--text-2); font-size: 12px; text-align: center; }

.frequent-grid { display: grid; height: 100%; padding: 26px 10px 10px; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); grid-auto-rows: 1fr; gap: 4px; overflow: hidden; }
.frequent-item { display: flex; min-width: 0; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border-radius: 12px; color: var(--text); font-size: 12px; text-align: center; }
.frequent-item:hover { background: var(--hover); }
.frequent-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 4px; }

.clock { display: flex; height: 100%; flex-direction: column; align-items: center; justify-content: center; color: var(--text); font-variant-numeric: tabular-nums; }
.clock-time { font-size: 34px; font-weight: 650; letter-spacing: -0.02em; line-height: 1; }
.clock-small .clock-time { font-size: 28px; }
.clock-day, .clock-date { margin-top: 6px; color: var(--text-2); font-size: 13px; }
.clock-wide { align-items: flex-start; padding: 0 22px; }
.clock-wide .clock-time { font-size: 44px; }
.clock-day-name { margin-right: 6px; color: var(--text); font-weight: 600; text-transform: capitalize; }
.clock-face { gap: 4px; padding: 18px 12px 12px; }
.clock-face svg { width: 74%; max-width: 170px; }
.clock-rim { fill: color-mix(in srgb, var(--bg-elev, #fff) 70%, transparent); stroke: var(--border-strong, rgba(0, 0, 0, 0.14)); stroke-width: 1.5; }
.clock-tick { stroke: var(--text-2); stroke-width: 2; stroke-linecap: round; }
.clock-hour, .clock-minute { stroke: var(--text); stroke-linecap: round; }
.clock-hour { stroke-width: 4; }
.clock-minute { stroke-width: 2.6; }
.clock-pin { fill: var(--accent); }

.widget-picker { width: min(560px, 100%); max-height: min(640px, calc(100vh - 48px)); overflow-y: auto; }
.widget-config { width: min(520px, 100%); padding: 0; overflow: hidden; }
.widget-config-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; font-weight: 650; }
.widget-config .widget-config-head { margin: 0; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.widget-config-frame { display: block; width: 100%; height: min(560px, 70vh); border: 0; }
.widget-hint { color: var(--text-2); font-size: 13px; }
.widget-catalog { display: flex; flex-direction: column; gap: 6px; }
.widget-option { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; }
.widget-option-text { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.widget-option-text span { color: var(--text-2); font-size: 12px; }
.widget-sizes { display: flex; flex-wrap: wrap; gap: 6px; }
.widget-sizes .btn { gap: 6px; }
.size-glyph { display: inline-block; width: 10px; height: 10px; border: 1.5px solid currentColor; border-radius: 3px; }
.size-glyph.w-2x1 { width: 18px; }
.size-glyph.w-2x2 { width: 14px; height: 14px; }
.size-glyph.w-4x2 { width: 22px; height: 12px; }
.popover-item.active { color: var(--text-2); }


/* ---------- Стол: единый стандарт (шаг 19.8) ----------
   Иконки модулей, док и виджеты выглядят одинаково во всех стилях; стиль меняет только токены. */
.desktop .desk-item .ws-tile,
.dock-item:not(.recent-app) {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}
.desktop .desk-item .ws-tile { width: 60px; height: 60px; border-radius: 16px; }
.dock-item { border-radius: 12px; }
.dock-item.recent-app { border: 0; background: var(--accent); color: var(--on-accent); }
.desktop .desk-item:hover .ws-tile { transform: translateY(-2px); }
.desk-widget { border-color: var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-sm); }
.desk-ghost { border-radius: 16px; }
/* В «Минимализме» поверхности непрозрачные: размытие под ними ничего не видно, но каждый кадр переноса его перерисовывает. */
:root:not([data-design="cosmos"]):not([data-design="couture"]) :is(.desktop .desk-item .ws-tile, .dock-item, .desk-widget) {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.widget-head { display: flex; align-items: center; justify-content: space-between; height: 34px; padding: 0 14px; color: var(--text-2); font-size: 11px; font-weight: 500; }
.clock-time, .clock-date, .clock-day { font-family: var(--num-font); font-variant-numeric: lining-nums tabular-nums; }
.clock-time { font-weight: 300; }
.clock-wide { flex-direction: row; align-items: center; justify-content: space-between; padding: 0 20px; }
.clock-wide .clock-date { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; margin: 0; font-family: var(--font); font-size: 12px; }
.clock-wide .clock-day-name { margin: 0; }
.frequent-grid { height: calc(100% - 34px); padding: 0 10px 10px; }
.menubar { height: 40px; }

/* ---------- Док из избранного (шаг 19.13) ---------- */
.dock-item { position: relative; }
/* Точка под элементом, чей экран открыт. */
.dock-item.running::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--text-2);
}
.dock-item.unavailable { opacity: 0.5; }
.dock-item.dragging { opacity: 0.35; }
/* Место вставки — перед элементом, конец — подсветка дока. */
.dock-item.drop-before { box-shadow: -6px 0 0 -3px var(--accent); }
.dock.drop-end { box-shadow: var(--shadow), 0 0 0 2px var(--accent); }
.dock-menu { transform: translateY(-100%); }
.stack-veil.passthrough,
.dock-stack.passthrough { pointer-events: none; }
.dock-stack.passthrough { opacity: 0.4; }

.palette-backdrop.passthrough { pointer-events: none; opacity: 0.35; }

/* ---------- Телефон (до 640px): строка меню, стол и док ----------
   Шаг клетки стола 72×92 — константа `PHONE` в `views/desktop.rs`, плитки здесь под него. */
.menubar { min-width: 0; }
.menubar-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menubar-logo { flex: none; white-space: nowrap; }
@media (max-width: 640px) {
  .menubar { gap: 6px; padding: 0 8px; padding-top: env(safe-area-inset-top); }
  .menubar .logo-name,
  .menubar .theme-switch,
  .menubar-clock { display: none; }
  .menubar-logo .logo-mark { width: 22px; height: 22px; }
  .menubar-btn { width: 34px; height: 34px; }
  .menubar-profile { margin-left: 2px; }

  .desktop-main { padding: 14px 12px 104px; }
  .desk-item { gap: 4px; padding: 4px 0; }
  .desktop .desk-item .ws-tile { width: 54px; height: 54px; border-radius: 14px; }
  .desk-item .file-tile { width: 46px; height: 56px; }
  .desk-label { font-size: 11px; line-height: 1.25; }
  .desk-item:hover .ws-tile,
  .desk-item:hover .folder-tile,
  .desk-item:hover .file-tile,
  .desktop .desk-item:hover .ws-tile { transform: none; }
  .desk-widget { border-radius: 14px; }
  /* Касанием не наводят: кнопка меню виджета видна всегда, заголовок ручки не дублирует заголовок виджета. */
  .widget-grip { opacity: 1; height: 26px; padding: 0 2px; background: none; justify-content: flex-end; }
  .desk-widget:hover .widget-grip { background: none; }
  .widget-grip .widget-title { display: none; }
  .widget-more { width: 26px; height: 26px; }
  .widget-head { height: 28px; padding: 0 10px; }
  .clock-time { font-size: 26px; }
  .clock-small .clock-time { font-size: 20px; }
  /* Широкие часы на телефоне: время над датой, иначе «Воскресенье» не помещается. */
  .clock-wide { flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; padding: 0 12px; }
  .clock-wide .clock-time { font-size: 32px; }
  .clock-wide .clock-date { flex-direction: row; align-items: baseline; gap: 5px; font-size: 11px; }
  .clock-face { padding: 10px 8px 8px; }

  .dock {
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    gap: 6px;
    max-width: none;
    padding: 6px 8px;
    border-radius: 18px;
    transform: none;
    justify-content: flex-start;
    scrollbar-width: none;
  }
  .dock::-webkit-scrollbar { display: none; }
  .dock-item { width: 42px; height: 42px; border-radius: 11px; }
  .dock-item:hover,
  .dock-item.recent-app.open { transform: none; }
  .dock-sep { height: 26px; margin: 0; }
  /* «История» всегда видна у правого края, даже когда избранное прокручивается. */
  .dock-item.recent-app { position: sticky; right: 0; margin-left: auto; box-shadow: -10px 0 12px -6px var(--glass-bg, rgba(0, 0, 0, 0.3)); }
  .dock-stack { left: 8px; right: 8px; bottom: calc(72px + env(safe-area-inset-bottom)); width: auto; max-width: none; transform: none; animation-name: stack-up-phone; }
  .context-menu { max-width: calc(100vw - 16px); }
  /* Экран модуля — во всю ширину между строкой меню и доком. */
  .service-main { inset: 40px 0 calc(66px + env(safe-area-inset-bottom)); }
  .service-frame { border-width: 1px 0; border-radius: 0; }
}
@keyframes stack-up-phone { from { opacity: 0; transform: translateY(10px); } }
