/* MyCloud — браузерный клиент.
   Оформление: светлое стекло на пастельном «приливе» (вариант 09-pastel-tide):
   фон страницы — бледный градиент мята → лаванда → персик, по нему медленно
   движутся размытые пятна, панели — полупрозрачное белое стекло с размытием.
   Значки папок и файлов — в духе последних версий macOS (папка с ярлычком,
   лист с загнутым углом и подписью типа). Никаких внешних ресурсов: всё рисуется
   средствами CSS, шрифты — системные. */

:root {
  --bg: #f7f9fd;
  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.74);
  --glass-edge: rgba(255, 255, 255, 0.78);
  --stroke: rgba(28, 42, 84, 0.10);
  --stroke-soft: rgba(28, 42, 84, 0.07);
  --text: #1b2230;
  --text-dim: #4e5867;
  --text-faint: #5c6677;
  --accent: #2f6fe4;
  --accent-ink: #1e4fa8;
  --accent-soft: rgba(47, 111, 228, 0.12);
  --danger: #c62f2f;
  --danger-ink: #a32323;
  --radius-lg: 24px;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 24px 60px rgba(28, 42, 84, 0.12), 0 2px 6px rgba(28, 42, 84, 0.06);
  --shadow-sm: 0 10px 26px rgba(28, 42, 84, 0.10);
  --font: -apple-system, "Segoe UI Variable Text", "Segoe UI", system-ui, Roboto, sans-serif;
}

* { box-sizing: border-box; }

/* Атрибут hidden должен побеждать собственные display у .login, .shell, .grid, .inspector, .empty:
   правило автора сильнее правила браузера, поэтому без этой строки скрытые экраны (вход после
   входа в систему, сетка в режиме списка, закрытый инспектор, пустое состояние) остаются на
   странице и перекрывают друг друга. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body { overflow: hidden; }

/* Фон: бледный пастельный градиент и три мягких пятна, которые медленно «накатывают».
   Пятна анимируются только transform — один слой композиции, без пересчёта макета. */
.backdrop {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: linear-gradient(135deg, #f1faf6 0%, #f4f2fc 46%, #fff5ee 100%);
}

/* Пелена поверх пятен: держит центр светлым, а края — спокойными. */
.backdrop::after {
  content: "";
  position: absolute;
  inset: -10%;
  background:
    radial-gradient(60% 55% at 50% 44%, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0) 72%),
    radial-gradient(45% 40% at 12% 92%, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 70%);
  animation: veil-breathe 34s ease-in-out infinite alternate;
  will-change: opacity;
}

.glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(96px);
  opacity: 0.7;
  will-change: transform;
}

.glow-a { width: 46vw; height: 40vw; left: -10vw; top: -6vw;  background: #cfe4fd; animation: tide-a 26s ease-in-out infinite alternate; }
.glow-b { width: 40vw; height: 36vw; right: -8vw; top: 4vw;   background: #e2d9ff; opacity: 0.62; animation: tide-b 36s ease-in-out infinite alternate; }
.glow-c { width: 44vw; height: 38vw; left: 24vw; bottom: -16vw; background: #d3eee2; opacity: 0.6; animation: tide-c 46s ease-in-out infinite alternate; }

@keyframes tide-a {
  from { transform: translate3d(-4vw, 0, 0) scale(0.94); }
  to   { transform: translate3d(34vw, 6vw, 0) scale(1.16); }
}
@keyframes tide-b {
  from { transform: translate3d(0, -2vw, 0) scale(1.06); }
  to   { transform: translate3d(-30vw, 8vw, 0) scale(0.92); }
}
@keyframes tide-c {
  from { transform: translate3d(-6vw, 0, 0) scale(1); }
  to   { transform: translate3d(26vw, -8vw, 0) scale(1.12); }
}
@keyframes veil-breathe {
  from { opacity: 0.72; }
  to   { opacity: 1; }
}

/* Стекло: один и тот же слой для всех панелей. */
.glass {
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(26px) saturate(165%);
  -webkit-backdrop-filter: blur(26px) saturate(165%);
}

/* Марка */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 34px; height: 28px; fill: #2f6fe4; }
.brand-mark .brand-arrow { fill: none; stroke: #ffffff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.brand-name { font-size: 17px; font-weight: 650; letter-spacing: 0.2px; }
.brand-note { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }
.brand-lg { margin-bottom: 22px; }
.brand-lg .brand-mark { width: 44px; height: 36px; }

/* Вход */
.login {
  position: relative;
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-card { width: min(420px, 100%); padding: 32px 30px 28px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  font: inherit;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.field input::placeholder { color: #8b95a5; }
.field input:hover { background: rgba(255, 255, 255, 0.86); }
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47, 111, 228, 0.16); background: #fff; }
.field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.hint { font-size: 12.5px; line-height: 1.5; color: var(--text-faint); margin: 16px 0 0; }
.note { font-size: 13px; line-height: 1.5; color: var(--text-dim); margin: 0; }
.error { color: var(--danger-ink); font-size: 13px; margin: 4px 0 12px; }

/* Кнопки */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 550;
  color: var(--text);
  background: var(--glass-strong);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
.button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.button:hover { background: rgba(255, 255, 255, 0.92); }
.button:active { transform: scale(0.98); }
.button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.button.primary { background: #2f6fe4; border-color: rgba(47, 111, 228, 0.85); color: #ffffff; box-shadow: 0 10px 24px rgba(47, 111, 228, 0.22); }
.button.primary:hover { background: #2560d0; }
.button.danger { background: rgba(198, 47, 47, 0.10); border-color: rgba(198, 47, 47, 0.30); color: var(--danger-ink); }
.button.danger:hover { background: rgba(198, 47, 47, 0.18); }
.button.ghost { background: rgba(255, 255, 255, 0.5); }
.button.wide { width: 100%; }
.button.small { padding: 8px 12px; font-size: 13px; }
.button.icon { padding: 10px; }
.button[disabled] { opacity: 0.5; cursor: default; }

/* Оболочка приложения */
.shell {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 18px;
  padding: 18px;
}

.sidebar { display: flex; flex-direction: column; padding: 20px 16px 16px; min-height: 0; }
.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 22px; }
.nav-secondary { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--stroke-soft); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  text-align: left;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 13px;
  cursor: pointer;
}
.nav-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav-item:hover { background: rgba(255, 255, 255, 0.72); color: var(--text); }
.nav-item.active { background: var(--accent-soft); border-color: rgba(47, 111, 228, 0.32); color: var(--accent-ink); font-weight: 600; }
.nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.nav-item .nav-badge { margin-left: auto; font-size: 12px; color: var(--text-faint); }

.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding-top: 14px; border-top: 1px solid var(--stroke-soft); }
.user { display: flex; align-items: center; gap: 9px; min-width: 0; }
.avatar {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, #7aa7f2, #4a86f0);
  color: #ffffff; font-weight: 650; font-size: 13px;
}
.user-name { font-size: 13.5px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Правая часть */
.content { display: flex; flex-direction: column; gap: 16px; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: var(--radius); flex-wrap: wrap; }
.topbar-tools { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-wrap: wrap; }

.crumbs { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; min-width: 0; }
.crumb {
  padding: 7px 11px;
  font: inherit;
  font-size: 13.5px;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-radius: 9px;
  cursor: pointer;
}
.crumb:hover { background: rgba(255, 255, 255, 0.72); color: var(--text); }
.crumb.current { color: var(--text); font-weight: 600; }
.crumb-sep { color: var(--text-faint); font-size: 12px; padding: 0 1px; }

.search {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--stroke);
  border-radius: 12px;
}
.search svg { width: 16px; height: 16px; fill: none; stroke: var(--text-faint); stroke-width: 1.8; stroke-linecap: round; }
.search input { width: 170px; background: none; border: none; color: var(--text); font: inherit; font-size: 13.5px; }
.search input:focus { outline: none; }
/* Кольцо мыши гасится намеренно (рамку рисует сам .search), но с клавиатуры его нечем заменить:
   Tab упирался в поле поиска, и человек не видел, где находится (шестой разбор 06.10.2026). */
.search input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.segmented { display: flex; gap: 2px; padding: 2px; background: rgba(255, 255, 255, 0.6); border: 1px solid var(--stroke); border-radius: 12px; }
.seg { padding: 7px 9px; background: none; border: none; border-radius: 9px; cursor: pointer; color: var(--text-dim); }
.seg svg { width: 16px; height: 16px; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.seg.active { background: #ffffff; color: var(--accent-ink); box-shadow: 0 2px 8px rgba(28, 42, 84, 0.10); }
.seg:focus-visible { outline: 2px solid var(--accent); }

/* Рабочая область */
.stage { flex: 1; display: grid; grid-template-columns: 1fr; gap: 16px; min-height: 0; }
.stage.with-inspector { grid-template-columns: 1fr 320px; }

.files {
  position: relative;
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.statusline { margin: 14px 2px 0; font-size: 12.5px; color: var(--text-faint); }

/* Скелетон папки (задача 55 плана F): пока список в пути, вместо пустого экрана — бледные
   заготовки плиток. Движение — бегущий блик; при «уменьшить движение» блик замирает
   (prefers-reduced-motion ниже). */
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 6px;
}
.skeleton-tile {
  height: 96px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(28, 42, 84, 0.05) 25%, rgba(28, 42, 84, 0.10) 37%, rgba(28, 42, 84, 0.05) 63%);
  background-size: 400% 100%;
  animation: skeleton-sweep 1.4s ease infinite;
}
@keyframes skeleton-sweep {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}

/* Пакетные действия мультивыбора (задача 53 плана F): бар над списком, виден только пока
   выбрано больше одной записи. */
.batchbar {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  z-index: 14;
  font-size: 13px;
}
#batchCount { color: var(--text-dim); white-space: nowrap; }

/* Сетка файлов */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 6px;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 8px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
  font: inherit;
  text-align: center;
}
.tile:hover { background: rgba(255, 255, 255, 0.7); }
.tile.selected { background: var(--accent-soft); border-color: rgba(47, 111, 228, 0.34); }
/* Мультивыбор (задача 53 плана F): выбранные набором записи отличаются от карточки одиночного
   выбора — иначе непонятно, сколько уже выбрано и уйдёт ли в пакетное удаление. */
.tile.multi-selected { background: var(--accent-soft); border-color: rgba(47, 111, 228, 0.34); box-shadow: inset 0 0 0 1px rgba(47, 111, 228, 0.34); }
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tile .tile-name {
  font-size: 13px;
  line-height: 1.35;
  max-width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.tile .tile-note { font-size: 11.5px; color: var(--text-faint); }

/* Значки: папка в духе macOS — с ярлычком, двухцветная, с бликом. */
.icon { width: 74px; height: 60px; position: relative; flex: none; }

.icon-folder .folder-body {
  position: absolute;
  inset: 8px 2px 2px 2px;
  border-radius: 8px 8px 9px 9px;
  background: linear-gradient(180deg, #8fd0ff 0%, #4b9dff 45%, #2f7ded 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), 0 6px 14px rgba(20, 60, 140, 0.24);
}
.icon-folder .folder-tab {
  position: absolute;
  left: 6px; top: 3px;
  width: 30px; height: 12px;
  border-radius: 6px 8px 0 0;
  background: linear-gradient(180deg, #a9dcff, #6fb5ff);
}
.icon-folder .folder-gloss {
  position: absolute;
  left: 8px; right: 8px; top: 12px; height: 12px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0));
}

/* Значок файла: белый лист с загнутым углом и подписью типа. */
.icon-file .sheet {
  position: absolute;
  inset: 4px 12px 2px 12px;
  background: linear-gradient(180deg, #ffffff, #eef3fb);
  border-radius: 5px 12px 5px 5px;
  box-shadow: 0 6px 16px rgba(10, 25, 60, 0.18), inset 0 0 0 1px rgba(120, 150, 200, 0.35);
}
.icon-file .sheet::after {
  content: "";
  position: absolute;
  right: 0; top: 0;
  border-width: 0 13px 13px 0;
  border-style: solid;
  border-color: transparent rgba(186, 203, 226, 0.85) transparent transparent;
  border-radius: 0 10px 0 0;
}
.icon-file .badge {
  position: absolute;
  left: 14px; bottom: 8px;
  padding: 2px 5px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #fff;
  border-radius: 4px;
  background: #475569;
}
/* Фоны подписей затемнены до контраста ≥ 4.5:1 с белым текстом: на прежних цветах (#f97316 = 2.80,
   #16a34a = 3.30, #8b5cf6 = 4.23) подпись типа читалась плохо, а она заменяет превью. */
.icon-file.k-image .badge { background: #c2410c; }
.icon-file.k-video .badge { background: #6d28d9; }
.icon-file.k-audio .badge { background: #be185d; }
.icon-file.k-document .badge { background: #2563eb; }
.icon-file.k-table .badge { background: #15803d; }
.icon-file.k-slide .badge { background: #9a3412; }
.icon-file.k-archive .badge { background: #a16207; }
.icon-file.k-code .badge { background: #0f766e; }
.icon-file.k-text .badge { background: #475569; }

/* Миниатюра изображения вместо значка: настоящий вид файла, как в macOS.
   cursor: zoom-in — щелчок по ней открывает полноэкранный предпросмотр (задача 9 плана F). */
.icon-file .thumb-image {
  position: absolute;
  inset: 4px 12px 2px 12px;
  border-radius: 5px 12px 5px 5px;
  background: #e9eef6 center/cover no-repeat;
  box-shadow: 0 6px 16px rgba(10, 25, 60, 0.18), inset 0 0 0 1px rgba(150, 175, 210, 0.5);
  cursor: zoom-in;
}

/* Список */
.list { width: 100%; border-collapse: collapse; }
.list th {
  text-align: left;
  font-size: 12px;
  font-weight: 550;
  color: var(--text-faint);
  padding: 6px 10px;
  border-bottom: 1px solid var(--stroke-soft);
}
/* Сортируемый заголовок (задача 52 плана F): кнопка в ячейке, стрелка направления добавляется
   текстом из app.js, aria-sort сообщает направление диктору. */
.list th .th-sort {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-weight: inherit;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.list th .th-sort:hover { color: var(--text); }
.list th .th-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.list th[aria-sort]:not([aria-sort="none"]) .th-sort { color: var(--accent-ink); }
.list td { padding: 9px 10px; font-size: 13.5px; border-bottom: 1px solid rgba(28, 42, 84, 0.05); }
.list tr { cursor: pointer; }
.list tbody tr:hover { background: rgba(255, 255, 255, 0.62); }
.list tbody tr.selected { background: var(--accent-soft); }
/* Мультивыбор в списке (задача 53 плана F): то же выделение, что у плитки multi-selected. */
.list tbody tr.multi-selected { background: var(--accent-soft); }
/* Строка списка принимает фокус с клавиатуры (`row.tabIndex = 0` в js/app.js), и без кольца
   человек не видел, на какой строке стоит: Tab уходил в никуда (шестой разбор 06.10.2026). */
.list tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.list .cell-name { display: flex; align-items: center; gap: 10px; }
.list .icon { width: 26px; height: 22px; }
.list .icon-folder .folder-body { inset: 3px 1px 1px 1px; border-radius: 3px 3px 4px 4px; }
.list .icon-folder .folder-tab { left: 2px; top: 1px; width: 11px; height: 5px; border-radius: 2px 3px 0 0; }
.list .icon-folder .folder-gloss { display: none; }
.list .icon-file .sheet, .list .icon-file .thumb-image { inset: 2px 4px 1px 4px; border-radius: 2px 5px 2px 2px; }
.list .icon-file .sheet::after { border-width: 0 7px 7px 0; }
.list .icon-file .badge { display: none; }
.list .num { color: var(--text-dim); white-space: nowrap; }

/* Инспектор */
.inspector { padding: 18px; display: flex; flex-direction: column; gap: 16px; overflow: auto; }
.inspector-head { display: flex; align-items: center; gap: 12px; }
.inspector-head .button.icon { margin-left: auto; }
/* Миниатюра в инспекторе: тот же значок, но меньшего размера и без подписи типа. */
.thumb { width: 54px; height: 46px; flex: none; position: relative; display: grid; place-items: center; }
.thumb .icon { width: 46px; height: 40px; }
.thumb .icon-file .badge { display: none; }
.thumb .icon-file .sheet, .thumb .icon-file .thumb-image { inset: 3px 8px 2px 8px; border-radius: 3px 8px 3px 3px; }
.thumb .icon-file .sheet::after { border-width: 0 8px 8px 0; }
.inspector-name { font-size: 15px; font-weight: 600; word-break: break-word; }
.inspector-kind { font-size: 12.5px; color: var(--text-faint); margin-top: 3px; }

.facts { margin: 0; display: grid; gap: 10px; }
.facts > div { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.facts dt { color: var(--text-faint); }
.facts dd { margin: 0; text-align: right; color: var(--text); word-break: break-word; }
.inspector-actions { margin-top: auto; display: grid; gap: 8px; }

/* Устройства (задача 13 плана F) */
.device-list { display: grid; gap: 10px; }
.device-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 15px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--stroke-soft);
  border-radius: 14px;
  flex-wrap: wrap;
}
.device-main { min-width: 0; }
.device-name { display: block; font-size: 14px; font-weight: 600; word-break: break-word; }
.device-facts { display: block; font-size: 12.5px; color: var(--text-faint); margin-top: 3px; }
.device-state { margin-left: auto; font-size: 12.5px; color: var(--text-faint); white-space: nowrap; }
.device-row > .button { margin-left: auto; }

/* Настройки (задача 15 плана F) */
.settings-rows { display: grid; gap: 12px; max-width: 760px; }
.settings-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--stroke-soft);
  border-radius: 14px;
  flex-wrap: wrap;
}
.settings-text { flex: 1; min-width: 220px; }
.settings-name { font-size: 14px; font-weight: 600; }
.settings-note { font-size: 12.5px; color: var(--text-dim); margin-top: 4px; line-height: 1.5; }
.settings-version { font-size: 13.5px; color: var(--text-dim); }

/* Корзина */
.trash-head { margin-bottom: 14px; }
.trash-head h2 { font-size: 17px; margin: 0 0 6px; }
.trash-head .button { margin-top: 8px; }
.trash-actions { display: flex; gap: 8px; margin-top: 10px; }
.trash-actions .button { padding: 8px 12px; font-size: 13px; }
/* У записи корзины две кнопки, поэтому плитки шире обычных, а кнопки переносятся на вторую строку,
   если не помещаются: иначе «Удалить навсегда» наезжает на соседнюю запись. */
#trashGrid { grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); }
#trashGrid .trash-actions { flex-wrap: wrap; justify-content: center; }
/* Догрузка страниц корзины: удалённого может быть больше, чем помещается в одну страницу */
.trash-more { display: flex; justify-content: center; margin-top: 14px; }

/* Перетаскивание: цель подсвечивается, когда над ней ведут файл или папку */
.tile.drop-target {
  outline: 2px solid rgba(150, 200, 255, 0.85);
  outline-offset: 2px;
  background: rgba(120, 180, 255, 0.14);
}

.list tbody tr.drop-target {
  outline: 2px solid rgba(150, 200, 255, 0.85);
  outline-offset: -2px;
  background: rgba(120, 180, 255, 0.16);
}

/* Крошка как цель: на неё узел поднимают в эту папку (первая крошка — корень пространства).
   Внутри папки это единственный способ вынести файл наружу: плитки кладут только «внутрь папки». */
.crumb.drop-target {
  outline: 2px solid rgba(150, 200, 255, 0.85);
  outline-offset: 1px;
  background: rgba(120, 180, 255, 0.18);
}

/* «Общая папка» в боковом списке как цель перетаскивания: файл скопируют туда, оригинал останется
   на месте. Подсветка та же, что у крошки, но обещание другое — потому и цвет другой, спокойнее. */
.nav-item.drop-target {
  outline: 2px solid rgba(150, 220, 180, 0.9);
  outline-offset: 1px;
  background: rgba(120, 210, 160, 0.2);
}

/* Перестановка: «перед» и «после» показываем полосой с той стороны, куда встанет узел.
   Так человек видит, что файл не уберут в папку, а поставят рядом — это разные действия. */
.tile.drop-before,
.list tbody tr.drop-before {
  box-shadow: inset 0 3px 0 0 rgba(150, 200, 255, 0.95);
}

.tile.drop-after,
.list tbody tr.drop-after {
  box-shadow: inset 0 -3px 0 0 rgba(150, 200, 255, 0.95);
}

/* Пусто */
.empty { display: grid; place-items: center; gap: 6px; padding: 60px 20px; text-align: center; }
.empty-folder {
  width: 92px; height: 74px; position: relative; opacity: 0.75;
  border-radius: 10px 10px 12px 12px;
  background: linear-gradient(180deg, rgba(47, 111, 228, 0.14), rgba(47, 111, 228, 0.05));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}
.empty-title { font-size: 15px; font-weight: 600; margin: 8px 0 0; }
.empty-note { font-size: 13px; color: var(--text-faint); margin: 0; max-width: 380px; }

/* Диалоги */
.dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 22px;
  color: var(--text);
  border-radius: var(--radius);
}
.dialog::backdrop { background: rgba(38, 52, 88, 0.26); backdrop-filter: blur(4px); }
.dialog h3 { margin: 0 0 14px; font-size: 16.5px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin: 18px 0 0; padding: 0; }

/* Полноэкранный предпросмотр (задачи 9–12 плана F): изображение по миниатюре,
   текст/PDF по кнопке «Предпросмотр» — временную ссылку показываем в iframe поверх страницы. */
.lightbox { width: min(960px, calc(100vw - 32px)); }
/* Появление окна (задача 57 плана F): мягкий всплытие вместо резкого «щёлк» — и гасится
   при prefers-reduced-motion вместе со скелетоном. */
.lightbox[open] { animation: lightbox-in 0.16s ease; }
@keyframes lightbox-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.lightbox-stage {
  display: grid;
  place-items: center;
  min-height: 220px;
  max-height: 70vh;
  border-radius: 14px;
  background: rgba(15, 27, 45, 0.06);
  overflow: hidden;
}
.lightbox-stage img { display: block; max-width: 100%; max-height: 70vh; object-fit: contain; }
.lightbox-stage iframe { width: 100%; height: 70vh; border: 0; background: #ffffff; }
.lightbox-meta { display: flex; align-items: baseline; gap: 12px; margin-top: 12px; }
.lightbox-name { font-size: 14px; font-weight: 600; word-break: break-word; }
.lightbox-count { margin-left: auto; font-size: 12.5px; color: var(--text-faint); white-space: nowrap; }
.lightbox .dialog-actions { flex-wrap: wrap; }

.versions { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 46vh; overflow: auto; }
.versions li {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--stroke-soft);
  border-radius: 13px;
}
.versions .v-main { min-width: 0; }
.versions .v-title { font-size: 13.5px; }
.versions .v-note { font-size: 12px; color: var(--text-faint); margin-top: 3px; }
.versions .button { margin-left: auto; padding: 7px 11px; font-size: 12.5px; }

/* Видимое сообщение о том, что интерфейс не загрузился */
.loaderror {
  position: fixed;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  max-width: min(680px, calc(100vw - 32px));
  padding: 14px 18px;
  font-size: 13.5px;
  line-height: 1.5;
  color: #8c1d18;
  background: rgba(255, 240, 240, 0.96);
  border: 1px solid rgba(198, 47, 47, 0.35);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  z-index: 30;
}
.loaderror strong { display: block; margin-bottom: 4px; }
.loaderror button { margin-top: 10px; }

/* Уведомление */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  padding: 12px 18px;
  font-size: 13.5px;
  border-radius: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px);
  z-index: 20;
}
.toast.bad { border-color: rgba(198, 47, 47, 0.35); color: var(--danger-ink); }

/* Передача файлов: видно, какой файл идёт и сколько уже передано */
.upload { padding: 12px 16px 14px; border-radius: var(--radius); }
.upload-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.upload-head > span:first-child { font-size: 13.5px; }
.upload-hint { font-size: 12px; color: var(--text-faint); margin-left: auto; }
.upload-track {
  margin-top: 9px;
  height: 6px;
  border-radius: 999px;
  background: rgba(15, 27, 45, 0.09);
  overflow: hidden;
}
.upload-bar {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7aa7f2, #4a86f0);
  transition: width 0.18s ease;
}

/* Подсказка при перетаскивании файлов с компьютера */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(232, 238, 248, 0.55);
  backdrop-filter: blur(3px);
  pointer-events: none;
}
.drop-card {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 28px 34px;
  text-align: center;
}
.drop-icon { width: 44px; height: 44px; fill: none; stroke: #2f6fe4; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.drop-title { font-size: 16px; font-weight: 600; }
.drop-note { font-size: 13px; color: var(--text-dim); }

/* Происходит загрузка */
.busy { opacity: 0.55; pointer-events: none; }

/* Узкая ширина: боковая панель — сверху, инспектор — поверх */
@media (max-width: 900px) {
  body { overflow: auto; }
  .shell { grid-template-columns: 1fr; height: auto; padding: 12px; }
  .sidebar { flex-direction: row; align-items: center; gap: 12px; flex-wrap: wrap; }
  .nav { flex-direction: row; margin: 0; flex-wrap: wrap; }
  .nav-secondary { border-top: none; padding-top: 0; margin-top: 0; }
  .sidebar-foot { margin: 0 0 0 auto; border-top: none; padding-top: 0; }
  /* Имя пользователя на узком экране уступает место кнопке «Выйти»: она должна быть видна. */
  .user-name { display: none; }
  .stage, .stage.with-inspector { grid-template-columns: 1fr; }
  .inspector { position: fixed; left: 12px; right: 12px; bottom: 12px; max-height: 62vh; z-index: 15; }
  .topbar-tools { width: 100%; margin-left: 0; }
  .search input { width: 100%; }
  .search { flex: 1; }
}

/* Телефон: тулбар в две строки, инспектор на всю ширину, касания-цели не меньше 44 px.
   Второй брейкпоинт (задачи 33-34 плана C): на 900px ещё помещается планшетная раскладка,
   а на телефоне 360-430 px та же раскладка даёт тесный тулбар и мелкие цели. */
@media (max-width: 560px) {
  /* Тулбар ложится в две строки: крошки отдельно, инструменты отдельно. Без этого на 360 px
     пять кнопок и поиск переносятся в хаотичный трёхрядник. */
  .topbar { align-items: stretch; }
  .crumbs { width: 100%; }
  .topbar-tools { justify-content: space-between; }

  /* Инспектор на всю ширину экрана: на 360 px фиксированные 12px слева и справа оставляют
     карточку шириной в почти весь экран, но max-height должен удержать её, чтобы список был
     виден под ней. */
  .inspector { left: 8px; right: 8px; bottom: 8px; max-height: 70vh; }

  /* Касание-цели: Apple и Google рекомендуют не меньше 44×44 px. Сегменты переключения вида,
     иконочные кнопки и строки корзины на телефоне растут до этого минимума — мышью ничего не
     теряется, а пальцем кнопка становится попадаемой. */
  .seg { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .button.icon { min-width: 44px; min-height: 44px; }
  #trashGrid .tile { min-height: 44px; }
  #trashGrid .trash-actions .button { min-height: 44px; min-width: 44px; }

  /* Длинные имена и крошки не растягивают страницу: имя обрезается с многоточием, крошка
     ужимается, а панель не уходит в горизонтальную прокрутку (задача 36 плана C). */
  .crumbs { flex-wrap: nowrap; overflow: hidden; }
  .crumb { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
  .tile .tile-name { max-width: 100%; }
  .cell-name { min-width: 0; }
  .cell-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .list { table-layout: fixed; }
  .list .cell-name { max-width: 60vw; }

  /* Лайтбокс на 360 px: окно почти во всю ширину, сцена и iframe меньше по высоте,
     кнопки переносятся, а счётчик уходит под имя (задача 35 плана F). */
  .lightbox { width: calc(100vw - 16px); padding: 14px; }
  .lightbox-stage { min-height: 140px; max-height: 56vh; }
  .lightbox-stage img { max-height: 56vh; }
  .lightbox-stage iframe { height: 56vh; }
  .lightbox-meta { flex-wrap: wrap; }
  .lightbox-count { margin-left: 0; }
}

/* Кому движение мешает (системная настройка «уменьшить движение») — фон замирает,
   бегущий блик скелетона и всплытие лайтбокса тоже: неподвижные заготовки читаются
   так же (задача 57 плана F). */
@media (prefers-reduced-motion: reduce) {
  .glow, .backdrop::after, .skeleton-tile, .lightbox { animation: none !important; }
}

/* ─── Тёмная тема (задачи 31–32 плана F) ─────────────────────────────────────
   Два входа в одни и те же токены: «как в системе» решает prefers-color-scheme
   (атрибута data-theme на <html> тогда нет), явный выбор — атрибут data-theme.
   Значения продублированы намеренно: медиазапрос и селектор атрибута не склеиваются
   в CSS, а проверка переменных (tests/web/app-css.test.mjs) читает оба блока. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151f;
    --glass: rgba(24, 29, 43, 0.66);
    --glass-strong: rgba(30, 36, 52, 0.82);
    --glass-edge: rgba(255, 255, 255, 0.10);
    --stroke: rgba(255, 255, 255, 0.14);
    --stroke-soft: rgba(255, 255, 255, 0.08);
    --text: #e9edf6;
    --text-dim: #aab4c6;
    --text-faint: #8792a6;
    --accent: #6ea0ff;
    --accent-ink: #9cbdfb;
    --accent-soft: rgba(110, 160, 255, 0.16);
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 10px 26px rgba(0, 0, 0, 0.40);
  }
}
:root[data-theme="dark"] {
  --bg: #12151f;
  --glass: rgba(24, 29, 43, 0.66);
  --glass-strong: rgba(30, 36, 52, 0.82);
  --glass-edge: rgba(255, 255, 255, 0.10);
  --stroke: rgba(255, 255, 255, 0.14);
  --stroke-soft: rgba(255, 255, 255, 0.08);
  --text: #e9edf6;
  --text-dim: #aab4c6;
  --text-faint: #8792a6;
  --accent: #6ea0ff;
  --accent-ink: #9cbdfb;
  --accent-soft: rgba(110, 160, 255, 0.16);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 10px 26px rgba(0, 0, 0, 0.40);
}

/* Жёсткие белые заливки светлой темы: в тёмной они горят пятнами, поэтому перечислены здесь
   явно (панели, поля, hover). Токены им не помогут — они записаны числами в правилах. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .backdrop { background: linear-gradient(135deg, #0e1622 0%, #141226 46%, #1a1410 100%); }
  :root:not([data-theme="light"]) .backdrop::after { background:
    radial-gradient(60% 55% at 50% 44%, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0) 72%),
    radial-gradient(45% 40% at 12% 92%, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0) 70%); }
  :root:not([data-theme="light"]) .button:hover { background: rgba(255, 255, 255, 0.12); }
  :root:not([data-theme="light"]) .button.ghost { background: rgba(255, 255, 255, 0.08); }
  :root:not([data-theme="light"]) .field input { background: rgba(255, 255, 255, 0.07); }
  :root:not([data-theme="light"]) .field input:hover { background: rgba(255, 255, 255, 0.11); }
  :root:not([data-theme="light"]) .field input:focus { background: rgba(18, 22, 34, 0.92); }
  :root:not([data-theme="light"]) .search { background: rgba(255, 255, 255, 0.07); }
  :root:not([data-theme="light"]) .segmented { background: rgba(255, 255, 255, 0.07); }
  :root:not([data-theme="light"]) .seg.active { background: rgba(255, 255, 255, 0.14); box-shadow: none; }
  :root:not([data-theme="light"]) .nav-item:hover,
  :root:not([data-theme="light"]) .crumb:hover { background: rgba(255, 255, 255, 0.09); }
  :root:not([data-theme="light"]) .tile:hover { background: rgba(255, 255, 255, 0.07); }
  :root:not([data-theme="light"]) .list tbody tr:hover { background: rgba(255, 255, 255, 0.07); }
  :root:not([data-theme="light"]) .versions li,
  :root:not([data-theme="light"]) .device-row,
  :root:not([data-theme="light"]) .settings-row { background: rgba(255, 255, 255, 0.06); }
  :root:not([data-theme="light"]) .toast { background: rgba(30, 36, 52, 0.96); }
  :root:not([data-theme="light"]) .dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
  :root:not([data-theme="light"]) .drop-overlay { background: rgba(10, 14, 22, 0.55); }
  :root:not([data-theme="light"]) .upload-track { background: rgba(255, 255, 255, 0.10); }
  :root:not([data-theme="light"]) .loaderror {
    color: #ffb4b0;
    background: rgba(64, 22, 22, 0.96);
    border-color: rgba(255, 120, 120, 0.35);
  }
}
:root[data-theme="dark"] .backdrop { background: linear-gradient(135deg, #0e1622 0%, #141226 46%, #1a1410 100%); }
:root[data-theme="dark"] .backdrop::after { background:
  radial-gradient(60% 55% at 50% 44%, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0) 72%),
  radial-gradient(45% 40% at 12% 92%, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0) 70%); }
:root[data-theme="dark"] .button:hover { background: rgba(255, 255, 255, 0.12); }
:root[data-theme="dark"] .button.ghost { background: rgba(255, 255, 255, 0.08); }
:root[data-theme="dark"] .field input { background: rgba(255, 255, 255, 0.07); }
:root[data-theme="dark"] .field input:hover { background: rgba(255, 255, 255, 0.11); }
:root[data-theme="dark"] .field input:focus { background: rgba(18, 22, 34, 0.92); }
:root[data-theme="dark"] .search { background: rgba(255, 255, 255, 0.07); }
:root[data-theme="dark"] .segmented { background: rgba(255, 255, 255, 0.07); }
:root[data-theme="dark"] .seg.active { background: rgba(255, 255, 255, 0.14); box-shadow: none; }
:root[data-theme="dark"] .nav-item:hover,
:root[data-theme="dark"] .crumb:hover { background: rgba(255, 255, 255, 0.09); }
:root[data-theme="dark"] .tile:hover { background: rgba(255, 255, 255, 0.07); }
:root[data-theme="dark"] .list tbody tr:hover { background: rgba(255, 255, 255, 0.07); }
:root[data-theme="dark"] .versions li,
:root[data-theme="dark"] .device-row,
:root[data-theme="dark"] .settings-row { background: rgba(255, 255, 255, 0.06); }
:root[data-theme="dark"] .toast { background: rgba(30, 36, 52, 0.96); }
:root[data-theme="dark"] .dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
:root[data-theme="dark"] .drop-overlay { background: rgba(10, 14, 22, 0.55); }
:root[data-theme="dark"] .upload-track { background: rgba(255, 255, 255, 0.10); }
:root[data-theme="dark"] .loaderror {
  color: #ffb4b0;
  background: rgba(64, 22, 22, 0.96);
  border-color: rgba(255, 120, 120, 0.35);
}
