/* ---------- Design tokens ----------
   Светлая гамма и четыре ярких цвета: синий, зелёный, жёлтый, красный. Всё, что имеет цвет,
   размер шрифта, радиус или тень, берёт значение отсюда: точечные литералы в правилах ниже —
   это баг, из-за которого гамма разъезжается по файлу. */

:root {
  color-scheme: light;

  /* Поверхности: холст → панель → подложка полей → наведение */
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --surface-3: #e5eaf3;

  --border: #e1e6ef;
  --border-strong: #c6cede;
  --border-hover: #aab5c9;        /* рамка поля под курсором и ползунок прокрутки под ним же */

  /* Текст: основной, вторичный, подписи */
  --text: #14171c;
  --text-2: #4a515c;
  --text-dim: #737b88;

  /* Четыре базовых цвета палитры. Всё цветное ниже — синий, зелёный, жёлтый или красный,
     пятого оттенка в интерфейсе нет. `-ink` — тот же цвет, но пригодный для мелкого текста
     на белом (контраст ≥ 4.5:1); `-soft` — подложка под иконку или строку. */
  --c-blue: #1f6bff;
  --c-blue-ink: #1b57d6;
  --c-blue-soft: rgba(31, 107, 255, 0.12);
  --c-green: #10a35a;
  --c-green-ink: #0a7a43;
  --c-green-soft: rgba(16, 163, 90, 0.14);
  --c-yellow: #f5a524;
  --c-yellow-ink: #96620a;
  --c-yellow-soft: rgba(245, 165, 36, 0.18);
  --c-red: #ef3e46;
  --c-red-ink: #c62234;
  --c-red-soft: rgba(239, 62, 70, 0.12);

  /* Ещё два слоя тех же четырёх цветов, для больших площадей: `-wash` — заливка целой
     карточки, `-line` — рамка вокруг неё. Прозрачнее, чем `-soft`: под значком цвет лежит
     на пятачке в сорок пикселей, а тут — на всей плитке, и та же плотность выжигает глаза.
     Жёлтый взят гуще остальных: на белом он светлее их всех и при равной альфе пропадает. */
  --c-blue-wash: rgba(31, 107, 255, 0.10);
  --c-blue-line: rgba(31, 107, 255, 0.30);
  --c-green-wash: rgba(16, 163, 90, 0.10);
  --c-green-line: rgba(16, 163, 90, 0.30);
  --c-yellow-wash: rgba(245, 165, 36, 0.16);
  --c-yellow-line: rgba(245, 165, 36, 0.40);
  --c-red-wash: rgba(239, 62, 70, 0.10);
  --c-red-line: rgba(239, 62, 70, 0.30);

  --accent: var(--c-blue);
  --accent-hover: #0d55e6;
  --accent-ink: var(--c-blue-ink);
  --accent-soft: var(--c-blue-soft);
  --accent-soft-strong: rgba(31, 107, 255, 0.20);

  --danger: var(--c-red);
  --danger-ink: var(--c-red-ink);
  --danger-soft: var(--c-red-soft);
  --danger-line: rgba(239, 62, 70, 0.34);
  --success: var(--c-green);
  --success-soft: var(--c-green-soft);

  /* Тип элемента — свой цвет из тех же четырёх: папка синяя, ссылка зелёная,
     текстовая страница жёлтая, документ красный. */
  --type-folder: var(--c-blue);
  --type-link: var(--c-green);
  --type-text: var(--c-yellow);
  --type-doc: var(--c-red);
  --type-folder-soft: var(--c-blue-soft);
  --type-link-soft: var(--c-green-soft);
  --type-text-soft: var(--c-yellow-soft);
  --type-doc-soft: var(--c-red-soft);
  --type-folder-wash: var(--c-blue-wash);
  --type-link-wash: var(--c-green-wash);
  --type-text-wash: var(--c-yellow-wash);
  --type-doc-wash: var(--c-red-wash);
  --type-folder-line: var(--c-blue-line);
  --type-link-line: var(--c-green-line);
  --type-text-line: var(--c-yellow-line);
  --type-doc-line: var(--c-red-line);

  --overlay-hover: rgba(20, 23, 28, 0.05);
  --overlay-hover-strong: rgba(20, 23, 28, 0.09);

  /* Шкала текста */
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 15px;
  --fs-xl: 17px;
  --fs-h2: 20px;

  /* Шкала радиусов */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 10px;
  --r-xl: 14px;

  /* Тени: двухслойные, чтобы край читался и на белом, и на --bg */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 2px 4px -2px rgba(16, 24, 40, 0.05), 0 6px 12px -4px rgba(16, 24, 40, 0.10);
  --shadow-lg: 0 8px 16px -6px rgba(16, 24, 40, 0.10), 0 20px 40px -12px rgba(16, 24, 40, 0.16);

  --ring: 0 0 0 3px rgba(31, 107, 255, 0.32);
  --ring-danger: 0 0 0 3px rgba(239, 62, 70, 0.30);

  /* Полоса из четырёх цветов под верхней панелью. */
  --stripe: linear-gradient(90deg, var(--c-blue) 0%, var(--c-green) 34%, var(--c-yellow) 67%, var(--c-red) 100%);

  --ease: cubic-bezier(0.2, 0, 0.2, 1);
  --dur: .14s;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "DejaVu Sans Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

.hidden { display: none !important; }

/* ---------- Фокус ----------
   Единственное правило фокуса на весь интерфейс. Ниже поля ввода гасят системный `outline`
   ради своей рамки — без этого блока клавиатурная навигация становится невидимой,
   а это уже не вопрос вкуса. `:focus-visible` не трогает клик мышью. */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
.field input:focus-visible,
.field textarea:focus-visible,
.field select:focus-visible,
.sidebar-search input:focus-visible,
.notepad-view textarea:focus-visible {
  outline: none;
}

/* ---------- Icons ----------
   Inline SVG replaces the emoji this UI used to draw icons with: emoji silently become empty
   boxes wherever no emoji font is installed, which is the normal state of a Linux desktop.
   Every icon inherits `currentColor`, so colour comes from the component around it. */

.icon {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
  vertical-align: -0.2em;
}

.icon-spin { animation: icon-spin 1.1s linear infinite; }
@keyframes icon-spin { to { transform: rotate(360deg); } }

/* ---------- Buttons ---------- */

.btn {
  /* Прозрачная рамка у всех вариантов: у .btn-ghost она видимая, и без этой заглушки
     кнопки рядом расходятся по высоте на два пикселя. */
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 9px 18px;
  font-size: var(--fs-md);
  font-weight: 550;
  line-height: 1.2;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease), color var(--dur) var(--ease),
              transform var(--dur) var(--ease);
  /* inline-flex so a leading .icon sits on the text baseline and keeps its gap; centring keeps
     the full-width buttons (auth, account) looking exactly as they did before icons existed. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.btn:active { transform: translateY(1px); }
.btn .icon { width: 16px; height: 16px; vertical-align: 0; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-md); }
.btn-primary:focus-visible { outline: none; box-shadow: var(--ring); }

.btn-ghost {
  background: var(--surface);
  color: var(--text-2);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:focus-visible { outline: none; box-shadow: var(--ring); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-ink); }
.btn-danger:focus-visible { outline: none; box-shadow: var(--ring-danger); }

/* Необратимое действие рядом с обратимым: «удалить навсегда» стоит бок о бок с
   «восстановить», и сплошная красная заливка перетянула бы на себя весь ряд. Красным здесь
   только текст, а цвет набирает силу под курсором. */
.btn-danger-ghost { color: var(--danger-ink); border-color: var(--danger-line); }
.btn-danger-ghost:hover {
  color: #fff; background: var(--danger); border-color: var(--danger);
}
.btn-danger-ghost:focus-visible { outline: none; box-shadow: var(--ring-danger); }
.btn-danger-ghost:disabled { color: var(--text-dim); border-color: var(--border); }

.btn-small { padding: 6px 12px; font-size: var(--fs-sm); }
.btn-small .icon { width: 15px; height: 15px; }

/* Кнопки создания над содержимым: те же четыре цвета и тот же приём с локальной переменной,
   что у карточек, — иконка, рамка и подложка под курсором берутся из неё.
   Класс ставит renderToolbar() в app.js. */
.btn-type-folder { --tint: var(--type-folder); --tint-wash: var(--type-folder-wash); --tint-line: var(--type-folder-line); }
.btn-type-link   { --tint: var(--type-link);   --tint-wash: var(--type-link-wash);   --tint-line: var(--type-link-line); }
.btn-type-text   { --tint: var(--type-text);   --tint-wash: var(--type-text-wash);   --tint-line: var(--type-text-line); }
.btn-type-doc    { --tint: var(--type-doc);    --tint-wash: var(--type-doc-wash);    --tint-line: var(--type-doc-line); }

.btn-type-folder, .btn-type-link, .btn-type-text, .btn-type-doc { border-color: var(--tint-line); }
.btn-type-folder .icon, .btn-type-link .icon,
.btn-type-text .icon, .btn-type-doc .icon { color: var(--tint); }
.btn-type-folder:hover, .btn-type-link:hover,
.btn-type-text:hover, .btn-type-doc:hover {
  border-color: var(--tint);
  background: linear-gradient(var(--tint-wash), var(--tint-wash)), var(--surface);
}

/* ---------- Landing page ---------- */

#landing {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 60% 55% at 10% 6%, var(--c-blue-soft), transparent 62%),
    radial-gradient(ellipse 55% 50% at 88% 12%, var(--c-green-soft), transparent 62%),
    radial-gradient(ellipse 55% 50% at 6% 92%, var(--c-yellow-soft), transparent 62%),
    radial-gradient(ellipse 60% 55% at 92% 88%, var(--c-red-soft), transparent 62%),
    linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
  overflow: hidden;
}

#landing::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(20, 23, 28, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 23, 28, 0.045) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 50% 40%, black 25%, transparent 72%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 40%, black 25%, transparent 72%);
  pointer-events: none;
}

.landing-topbar {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 26px 40px;
  z-index: 2;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: var(--fs-h2);
  font-weight: 650;
  letter-spacing: -0.015em;
}

.brand-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 9px;
  box-shadow: var(--shadow-sm);
}

.landing-hero {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 72px;
  padding: 0 60px 40px;
  z-index: 2;
}

.landing-copy { max-width: 560px; }

.landing-copy h1 {
  font-size: 46px;
  line-height: 1.1;
  letter-spacing: -0.025em;
  margin: 0 0 20px;
  color: var(--text);
}

.landing-copy p {
  font-size: var(--fs-xl);
  line-height: 1.6;
  color: var(--text-2);
  margin: 0 0 28px;
}

.feature-list {
  list-style: none;
  margin: 0 0 32px;
  padding: 0;
  display: grid;
  gap: 11px;
}

.feature-list li {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: var(--fs-lg);
  color: var(--text-2);
}

.feature-list .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  flex-shrink: 0;
  margin-left: 2px;
}
.feature-list li:nth-child(2) .dot { background: var(--c-green);  box-shadow: 0 0 0 4px var(--c-green-soft); }
.feature-list li:nth-child(3) .dot { background: var(--c-yellow); box-shadow: 0 0 0 4px var(--c-yellow-soft); }
.feature-list li:nth-child(4) .dot { background: var(--c-red);    box-shadow: 0 0 0 4px var(--c-red-soft); }

.landing-art { width: 420px; max-width: 40vw; flex-shrink: 0; }
.landing-art svg { width: 100%; height: auto; filter: drop-shadow(0 24px 48px rgba(16, 24, 40, 0.14)); }

@media (max-width: 900px) {
  .landing-hero { flex-direction: column; padding: 20px 24px 40px; gap: 24px; }
  .landing-art { width: 260px; max-width: 70vw; }
  .landing-copy h1 { font-size: 32px; }
  .landing-topbar { padding: 18px 20px; }
}

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 23, 28, 0.42);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: overlay-in .12s var(--ease);
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  width: 380px;
  max-width: 92vw;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  animation: modal-in .16s var(--ease);

  /* Окно «Аккаунт» переросло невысокий экран, и нижние поля стали недостижимы: страница под
     оверлеем не прокручивается, а само окно высоту не ограничивало. Прокрутка здесь, а не у
     оверлея, — иначе при коротком содержимом окно перестаёт стоять по центру.
     overscroll-behavior не даёт прокрутке «провалиться» на страницу за окном. */
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }

.modal.modal-wide { width: 520px; }

.modal-resizable {
  resize: both;
  overflow: auto;
  min-width: 340px;
  min-height: 280px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

/* The description/content textarea stretches to fill the modal when it's been maximized,
   instead of staying a small fixed-height box inside a lot of empty space. */
#item-form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#field-description:not(.hidden), #field-content:not(.hidden) {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
}
#field-description textarea, #field-content textarea {
  flex: 1; min-height: 0; resize: none;
}

.modal h2 { margin: 0 0 6px; font-size: var(--fs-h2); font-weight: 650; }
.modal .modal-sub { color: var(--text-dim); font-size: var(--fs-sm); margin: 0 0 22px; }

.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: var(--fs-sm); font-weight: 550;
  color: var(--text-2); margin-bottom: 6px;
}

.field input[type=text],
.field input[type=email],
.field input[type=password],
.field input[type=url],
.field textarea,
.field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-md);
  font-family: inherit;
  outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.field input::placeholder, .field textarea::placeholder { color: var(--text-dim); }
.field input:hover, .field textarea:hover, .field select:hover { border-color: var(--border-hover); }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.field textarea { resize: vertical; min-height: 100px; line-height: 1.55; }
.field input[type=file] {
  width: 100%; font-size: var(--fs-sm); color: var(--text-2);
}

.field-error {
  color: var(--danger-ink);
  font-size: var(--fs-sm);
  margin: -8px 0 14px;
  min-height: 1em;
}

.modal-actions {
  display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px;
}

.modal-switch {
  text-align: center;
  margin-top: 18px;
  font-size: var(--fs-sm);
  color: var(--text-dim);
}
.modal-switch a {
  color: var(--accent-ink); text-decoration: none; cursor: pointer; font-weight: 550;
}
.modal-switch a:hover { text-decoration: underline; }

.modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: var(--r-md);
  color: var(--text-dim);
  font-size: 20px; line-height: 1;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }

/* ---------- App shell ---------- */

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 20px;
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  z-index: 10;
}

/* Цветная полоса под панелью: она же задаёт порядок цветов, в котором дальше идут
   вкладки и типы элементов. */
.app-topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 4px;
  background: var(--stripe);
}

.app-topbar .brand { font-size: var(--fs-lg); gap: 9px; }
.app-topbar .brand-icon { width: 24px; height: 24px; border-radius: 7px; }

.tabs { display: flex; gap: 2px; margin-left: 22px; }
.tab-btn {
  background: none; border: 1px solid transparent; color: var(--text-dim);
  padding: 7px 13px; border-radius: var(--r-md);
  font-size: var(--fs-md); font-weight: 500;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tab-btn:hover { background: var(--overlay-hover); color: var(--text); }
.tab-btn.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}

/* Каждая вкладка красится своим цветом из палитры — по ней видно, где вы находитесь,
   не вчитываясь в подпись. Селектор по `data-view` из разметки, JS ничего не проставляет. */
.tab-btn.active[data-view="help"]     { background: var(--c-green-soft);  color: var(--c-green-ink); }
.tab-btn.active[data-view="admin"]    { background: var(--c-red-soft);    color: var(--c-red-ink); }
.tab-btn.active[data-view="notepad"]  { background: var(--c-yellow-soft); color: var(--c-yellow-ink); }
.tab-btn.active[data-view="terminal"] { background: var(--surface-3);     color: var(--text); }

.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-email { color: var(--text-dim); font-size: var(--fs-sm); }

/* `min-width: 0` обязателен: без него флекс-контейнер не даёт себя сузить ниже минимальной
   ширины содержимого, и на узком экране строка кнопок распирает всю правую часть за край
   экрана — карточки уезжают под обрез, а прокрутки страницы при этом нет. */
.app-body { flex: 1; display: flex; min-height: 0; min-width: 0; }

/* ---------- Explorer ---------- */

.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 8px;
}
.sidebar-header span {
  font-size: 11px; font-weight: 650; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-dim);
}

.sidebar-search { padding: 0 14px 10px; }
.sidebar-search input {
  width: 100%; padding: 8px 10px 8px 31px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text); font-size: var(--fs-sm);
  outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              background var(--dur) var(--ease);
  /* A placeholder can't hold a child element, so the magnifier that used to be a 🔍 in the
     placeholder text is drawn as a background image instead. Цвет здесь — константа
     (в data-URI переменную не подставить) и за токенами не следует. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23737b88' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20.5 20.5-4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
  background-size: 14px 14px;
}
.sidebar-search input::placeholder { color: var(--text-dim); }
.sidebar-search input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: var(--ring);
}

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  width: 27px; height: 27px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.icon-btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn:disabled:hover { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--accent); }
.icon-btn .icon { width: 16px; height: 16px; vertical-align: 0; }

.tree {
  flex: 1;
  overflow-y: auto;
  padding: 2px 8px 16px;
}

.tree-node { user-select: none; }

.tree-row {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 6px;
  border-radius: var(--r-sm);
  font-size: var(--fs-md);
  cursor: pointer;
  color: var(--text-2);
  white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tree-row:hover { background: var(--overlay-hover); color: var(--text); }
.tree-row.selected {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 550;
}
.tree-row.selected:hover { background: var(--accent-soft-strong); }

.tree-caret {
  width: 14px; color: var(--text-dim);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.tree-caret .icon { width: 12px; height: 12px; vertical-align: 0; }
.tree-caret.empty { visibility: hidden; }

/* Дерево состоит из одних папок, поэтому иконка здесь всегда синяя — цвет типа «папка». */
.tree-icon { color: var(--type-folder); display: flex; }
.tree-row.selected .tree-icon { color: var(--accent); }

.tree-menu-btn {
  background: none; border: none; color: var(--text-dim);
  line-height: 1; padding: 3px 4px; border-radius: 5px;
  margin-left: auto; flex-shrink: 0; opacity: 0;
  display: flex; align-items: center;
  transition: opacity var(--dur) var(--ease), background var(--dur) var(--ease);
}
.tree-menu-btn .icon { width: 15px; height: 15px; vertical-align: 0; }
/* Кнопка проявляется по наведению на строку. Клавиатура и касание её не «наводят»,
   поэтому фокус и выделенная строка открывают её тоже — иначе с клавиатуры до меню не дойти. */
.tree-row:hover .tree-menu-btn,
.tree-row.selected .tree-menu-btn,
.tree-row:focus-within .tree-menu-btn { opacity: 1; }
.tree-menu-btn:hover { background: var(--overlay-hover-strong); color: var(--text); }

.tree-children { margin-left: 15px; border-left: 1px solid var(--border); padding-left: 4px; }

/* ---------- Верхний уровень дерева ----------
   Корневая папка — вход в раздел, а не очередная ветка, поэтому её строка отличается от
   вложенной: значок на цветной подложке (та же, что под значком карточки в сетке), тёмный
   текст вместо вторичного и воздух между соседями. Класс `is-root` ставит renderTreeNode(). */

.tree-node.is-root + .tree-node.is-root { margin-top: 2px; }

.tree-row.is-root {
  gap: 8px;
  padding: 5px 6px;
  color: var(--text);
  font-weight: 550;
}

.tree-icon-tile {
  width: 28px; height: 28px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  background: var(--type-folder-soft);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--dur) var(--ease);
}
.tree-icon-tile .tree-icon { width: 17px; height: 17px; vertical-align: 0; }
.tree-row.is-root.selected .tree-icon-tile { background: var(--accent-soft-strong); }

/* Счётчик вложенного и кнопка меню занимают одну клетку справа и подменяют друг друга: в
   боковой панели шириной 280 пикселей на два элемента места не остаётся, а имя папки важнее
   обоих. Оба ребёнка кладутся в одну ячейку сетки, видимость решает opacity. */
.tree-tail {
  margin-left: auto;
  flex-shrink: 0;
  display: grid;
  justify-items: end;
  align-items: center;
}
.tree-tail > * { grid-area: 1 / 1; }

.tree-count {
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.5;
  color: var(--text-dim);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 0 7px;
  transition: opacity var(--dur) var(--ease);
}
/* На выделенной строке счётчик виден только на сенсорном экране (ниже), но серая плашка на
   синей подложке там смотрится заплаткой — цвет берётся из акцента. */
.tree-row.is-root.selected .tree-count { color: var(--accent-ink); background: var(--accent-soft-strong); }
.tree-row.is-root:hover .tree-count,
.tree-row.is-root.selected .tree-count,
.tree-row.is-root:focus-within .tree-count { opacity: 0; }

.empty-hint { color: var(--text-dim); font-size: var(--fs-sm); padding: 12px 8px; line-height: 1.55; }

/* ---------- Main content pane ---------- */

.content-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.content-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 22px; border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap; gap: 10px;
}

.breadcrumb {
  display: flex; align-items: center; gap: 5px;
  font-size: var(--fs-md); color: var(--text-dim); flex-wrap: wrap;
}
.breadcrumb > span { display: inline-flex; align-items: center; gap: 5px; }
.breadcrumb .crumb {
  cursor: pointer; color: var(--text-2);
  padding: 3px 6px; border-radius: var(--r-sm);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.breadcrumb .crumb:hover { color: var(--accent-ink); background: var(--accent-soft); }
.breadcrumb .sep { color: var(--border-strong); }

.toolbar-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.view-mode-toggle {
  display: flex; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 3px;
}
.view-mode-btn {
  background: none; border: none; color: var(--text-dim);
  height: 26px; padding: 0 10px; border-radius: var(--r-sm);
  font-size: var(--fs-sm); font-weight: 500;
  display: flex; align-items: center; justify-content: center; gap: 5px; white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.view-mode-btn .icon { width: 14px; height: 14px; vertical-align: 0; }
.view-mode-btn:hover { color: var(--text); }
.view-mode-btn.active {
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-sm);
}

.content-grid {
  flex: 1; overflow-y: auto; padding: 18px 22px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 12px;
  align-content: start;
}

.content-grid.list-mode {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 22px 18px;
}

.content-grid.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Цвет типа объявляется один раз локальными переменными, а правила ниже их читают: так один
   и тот же цвет попадает в заливку, рамку, полосу и значок, а селекторов на каждый тип
   остаётся по одному вместо пяти. Классы `type-*` ставит renderCard() в app.js. */
.item-card.type-folder {
  --tint: var(--type-folder); --tint-soft: var(--type-folder-soft);
  --tint-wash: var(--type-folder-wash); --tint-line: var(--type-folder-line);
}
.item-card.type-link {
  --tint: var(--type-link); --tint-soft: var(--type-link-soft);
  --tint-wash: var(--type-link-wash); --tint-line: var(--type-link-line);
}
.item-card.type-text {
  --tint: var(--type-text); --tint-soft: var(--type-text-soft);
  --tint-wash: var(--type-text-wash); --tint-line: var(--type-text-line);
}
.item-card.type-doc {
  --tint: var(--type-doc); --tint-soft: var(--type-doc-soft);
  --tint-wash: var(--type-doc-wash); --tint-line: var(--type-doc-line);
}

.item-card {
  /* Заливка идёт двумя слоями поверх белого, а не одним полупрозрачным цветом: под сеткой
     лежит серый холст, и на нём тот же цвет с той же альфой выглядел бы грязнее. */
  background: linear-gradient(var(--tint-wash, transparent), var(--tint-wash, transparent)), var(--surface);
  border: 1px solid var(--tint-line, var(--border));
  border-radius: var(--r-lg);
  padding: 14px 15px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}

/* Полоса по верху карточки — тот же приём, что у карточек типов в «Инструкции». В сетке она
   читается через всю страницу, когда сам значок ещё слишком мелкий, чтобы различить форму. */
.item-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--tint, transparent);
}

.item-card:hover {
  border-color: var(--tint, var(--border-strong));
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.item-card:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--accent); }

/* В списке та же полоса встаёт слева, а заливки нет: полсотни строк подряд, залитых каждая
   своим цветом, читаются хуже, чем строки с цветным краем. Цвет возвращается под курсором. */
.list-mode .item-card {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 7px 40px 7px 14px;
  border-radius: var(--r-md);
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}
.list-mode .item-card::before {
  top: 0; bottom: 0; right: auto;
  width: 3px; height: auto;
}
.list-mode .item-card:hover {
  transform: none;
  box-shadow: none;
  background: linear-gradient(var(--tint-wash, transparent), var(--tint-wash, transparent)), var(--surface);
  border-color: var(--tint-line, var(--border));
}

/* Тип элемента виден цветом иконки и подложкой под ней: в сетке из двух десятков карточек
   это быстрее, чем читать форму значка. Классы ставит renderCard() в app.js. */
.item-icon {
  color: var(--text-dim);
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  align-self: flex-start;
  flex-shrink: 0;   /* см. `.item-name`: иначе плитка значка сплющивается по высоте */
}
.item-icon .icon { width: 22px; height: 22px; vertical-align: 0; }
.list-mode .item-icon { width: 26px; height: 26px; border-radius: var(--r-sm); align-self: auto; }
.list-mode .item-icon .icon { width: 16px; height: 16px; }

/* Подложка значка гуще заливки карточки: на маленькой площади тот же цвет читается слабее.
   Значение берётся из `--tint-*`, объявленных выше у самой карточки. */
.item-card .item-icon { color: var(--tint, var(--text-dim)); background: var(--tint-soft, var(--surface-2)); }

.item-name {
  font-size: var(--fs-md); font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  /* `overflow: hidden` обнуляет минимальный размер флекс-элемента, поэтому в тесной по высоте
     сетке строка названия сжимается до нескольких пикселей и текст обрезается поперёк. Значку
     ниже — то же самое. Пусть лучше сетка прокручивается, чем карточка станет нечитаемой. */
  flex-shrink: 0;
}
.list-mode .item-name { font-weight: 500; }

/* Не `--text-dim`, как у прочих подписей: он рассчитан на белый фон и на цветной заливке
   карточки не дотягивает до 4.5:1, а шрифт здесь самый мелкий в интерфейсе. */
.item-desc {
  font-size: var(--fs-xs); color: var(--text-2); line-height: 1.45;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
  min-height: 2.6em;
}
.list-mode .item-desc { display: none; }

.item-menu-btn {
  position: absolute; top: 8px; right: 8px;
  background: none; border: none; color: var(--text-dim);
  padding: 3px 5px; border-radius: var(--r-sm);
  display: flex; align-items: center;
  opacity: 0;
  transition: opacity var(--dur) var(--ease), background var(--dur) var(--ease);
}
.item-menu-btn .icon { width: 16px; height: 16px; vertical-align: 0; }
/* `:focus-within` покрывает оба случая: фокус на самой карточке и фокус на кнопке внутри неё.
   Без него кнопка, доехавшая до фокуса табом, оставалась бы невидимой. */
.item-card:hover .item-menu-btn,
.item-card:focus-within .item-menu-btn { opacity: 1; }
.item-menu-btn:hover { background: var(--overlay-hover-strong); color: var(--text); }
/* На сенсорном экране наведения нет — там кнопка видна всегда. Подменять ею счётчик поэтому
   некому: хвост корневой строки раскладывается в ряд, и видно оба. */
@media (hover: none) {
  .item-menu-btn, .tree-menu-btn { opacity: 1; }
  .tree-tail { display: flex; gap: 4px; }
  .tree-row.is-root:hover .tree-count,
  .tree-row.is-root.selected .tree-count,
  .tree-row.is-root:focus-within .tree-count { opacity: 1; }
}

.context-menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 5px;
  min-width: 180px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: menu-in .1s var(--ease);
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.context-menu button {
  display: block; width: 100%; text-align: left;
  background: none; border: none; color: var(--text-2);
  padding: 8px 10px; border-radius: var(--r-sm); font-size: var(--fs-sm);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.context-menu button:hover { background: var(--surface-2); color: var(--text); }
.context-menu button.danger { color: var(--danger-ink); }
.context-menu button.danger:hover { background: var(--danger-soft); }
.context-menu hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; color: var(--text-dim); gap: 12px; text-align: center; padding: 40px;
  font-size: var(--fs-md);
}
.empty-state .big-icon {
  display: flex; align-items: center; justify-content: center;
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--accent-soft); border: 1px solid transparent;
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.empty-state .big-icon .icon { width: 34px; height: 34px; stroke-width: 1.4; vertical-align: 0; }

/* ---------- Admin panel ---------- */

.panel-view { flex: 1; overflow-y: auto; padding: 26px 32px 40px; }
.panel-view h2 { margin: 0 0 4px; font-size: 22px; font-weight: 650; }
.panel-view .panel-sub { color: var(--text-dim); font-size: var(--fs-sm); margin: 0 0 24px; }

table.data-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
table.data-table th, table.data-table td {
  padding: 11px 16px; text-align: left; font-size: var(--fs-md);
  border-bottom: 1px solid var(--border);
}
table.data-table th {
  color: var(--text-dim); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .06em;
  background: var(--surface-2);
}
table.data-table tbody tr:hover td { background: var(--surface-2); }
table.data-table tr:last-child td { border-bottom: none; }
.files-name-cell .icon { margin-right: 9px; color: var(--text-dim); }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.5;
}
.badge-admin { background: var(--accent-soft); color: var(--accent-ink); }
.badge-user { background: var(--surface-3); color: var(--text-dim); }

.file-drop {
  display: block;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-lg);
  padding: 22px;
  text-align: center;
  color: var(--text-dim);
  font-size: var(--fs-md);
  margin: 16px 0;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease),
              color var(--dur) var(--ease);
}
.file-drop:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.file-drop input { display: none; }

.section-title { margin: 32px 0 12px; font-size: var(--fs-xl); font-weight: 650; }
.section-title-row {
  display: flex; align-items: center; justify-content: space-between;
  margin: 32px 0 12px; flex-wrap: wrap; gap: 10px;
}

.danger-zone {
  margin-top: 26px;
  padding: 16px 18px;
  border: 1px solid var(--danger-line);
  background: var(--danger-soft);
  border-radius: var(--r-lg);
}
.danger-zone .field { margin-bottom: 12px; }
.danger-zone .section-title { color: var(--danger-ink); }

.files-toolbar {
  display: flex; align-items: center; gap: 8px;
  margin: 16px 0 4px;
}
.files-path {
  flex: 1; font-family: var(--font-mono); font-size: var(--fs-sm);
  color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 7px 12px; overflow-x: auto; white-space: nowrap;
}
.files-table-row-dir { cursor: pointer; }
.files-table-row-dir:hover td { color: var(--accent-ink); }

/* ---------- Оффлайн ---------- */

/* Полоса снизу, а не сверху: сверху она сдвигала бы всю раскладку и перекрывала вкладки. */
.offline-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  padding: 9px 16px; text-align: center;
  font-size: var(--fs-sm); font-weight: 600;
  color: var(--c-yellow-ink);
  background: var(--c-yellow-soft);
  border-top: 1px solid var(--c-yellow-line);
}
/* Без связи менять ничего нельзя — кнопки создания и загрузки гасим, чтобы человек не бился
   в форму, которая всё равно не сохранится. */
.is-offline .toolbar-actions .btn,
.is-offline #btn-new-root-folder,
.is-offline #btn-import-tree { opacity: .45; pointer-events: none; }

/* ---------- Выделение, перетаскивание, горячие клавиши ---------- */

.selection-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; margin: 0 0 2px;
  background: var(--accent-soft); border-bottom: 1px solid var(--border);
}
.selection-count { flex: 1; font-size: var(--fs-md); font-weight: 600; color: var(--accent-ink); }

.item-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
/* Перетаскиваемый элемент бледнеет: видно, что он «взят», а не остался на месте. */
.dragging { opacity: .45; }
/* Цель под курсором — синяя рамка и подложка. Тот же синий, что у выбранной папки:
   «сюда попадёт» и «здесь я сейчас» — соседние по смыслу состояния. */
.drop-target {
  background: var(--accent-soft) !important;
  box-shadow: 0 0 0 2px var(--accent) inset;
  border-radius: var(--r-md);
}

.hotkeys-table td:first-child { white-space: nowrap; width: 1%; }
kbd {
  display: inline-block; min-width: 20px; text-align: center;
  padding: 2px 7px; margin: 0 1px;
  font-family: var(--font-mono); font-size: var(--fs-xs); line-height: 1.5;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: var(--r-sm);
}

/* ---------- Боковая панель: избранное и битые ссылки ---------- */

.sidebar-filters { padding: 4px 10px 10px; border-bottom: 1px solid var(--border); }

.filter-row {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: var(--r-md); cursor: pointer;
  font-size: var(--fs-md); color: var(--text-2);
}
.filter-row:hover { background: var(--surface-2); color: var(--text); }
.filter-row:focus-visible { outline: none; box-shadow: var(--ring); }
.filter-row .icon { width: 17px; height: 17px; flex: none; }
.filter-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-count { color: var(--text-dim); font-size: var(--fs-sm); }

/* Избранное — жёлтое, битые ссылки — красные: те же четыре цвета палитры, что и у типов. */
.filter-fav .icon { color: var(--c-yellow); }
.filter-broken .icon { color: var(--c-red); }
.filter-row.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.filter-row.active .filter-count { color: var(--accent-ink); }

.filter-head {
  margin: 12px 0 6px; padding: 0 9px;
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-dim);
}
.filter-reset { margin: 10px 9px 0; }

/* ---------- Значки состояния на карточке ---------- */

.item-marks { display: flex; gap: 5px; }
.item-marks:empty { display: none; }
.item-marks .icon { width: 15px; height: 15px; }
.mark-fav { color: var(--c-yellow); fill: var(--c-yellow-soft); }
.mark-broken { color: var(--c-red); }
/* «Не удалось проверить» — не беда, а неизвестность: серый, без рамки на карточке. */
.mark-unverified { color: var(--text-dim); }
/* Битая ссылка не перекрашивается целиком: тип карточки важнее её состояния,
   поэтому от красного здесь только значок и рамка. */
.item-card.is-broken { border-color: var(--c-red-line); }

/* ---------- Текстовая страница: чтение ---------- */

.text-reader-head { display: flex; align-items: flex-start; gap: 14px; }
.text-reader-head h2 { flex: 1; margin: 0; font-size: var(--fs-xl); font-weight: 650; }
.text-reader-meta { color: var(--text-dim); font-size: var(--fs-sm); margin: 4px 0 16px; }

.md-body { overflow-y: auto; flex: 1; line-height: 1.62; color: var(--text); }
.md-body > :first-child { margin-top: 0; }
.md-body h1, .md-body h2, .md-body h3,
.md-body h4, .md-body h5, .md-body h6 { margin: 22px 0 8px; font-weight: 650; line-height: 1.3; }
.md-body h1 { font-size: 25px; }
.md-body h2 { font-size: 21px; }
.md-body h3 { font-size: 18px; }
.md-body h4, .md-body h5, .md-body h6 { font-size: var(--fs-md); }
.md-body p { margin: 0 0 12px; }
.md-body ul, .md-body ol { margin: 0 0 12px; padding-left: 26px; }
.md-body li { margin-bottom: 4px; }
.md-body a { color: var(--accent-ink); }
.md-body code {
  font-family: var(--font-mono); font-size: .92em;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 1px 5px;
}
.md-body pre {
  margin: 0 0 14px; padding: 12px 14px; overflow-x: auto;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md);
}
/* Внутри блока кода рамка и подложка уже есть у самого блока — на каждой строке они лишние. */
.md-body pre code { background: none; border: none; padding: 0; font-size: var(--fs-sm); }
.md-body blockquote {
  margin: 0 0 14px; padding: 4px 0 4px 14px;
  border-left: 3px solid var(--border-strong); color: var(--text-2);
}
.md-body hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.md-empty { color: var(--text-dim); }

.md-hint { margin-top: 7px; color: var(--text-dim); font-size: var(--fs-xs); }
.md-hint code {
  font-family: var(--font-mono);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 0 4px;
}

/* ---------- Корзина ---------- */

.trash-toolbar {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 14px;
}
/* Очистка корзины уезжает вправо: это единственное необратимое действие на экране,
   и соседство с «Обновить» подталкивало бы нажать его не глядя. */
#trash-purge-all-btn { margin-left: auto; }

/* Значок типа в списке красится так же, как карточка в проводнике: тот же цвет — тот же тип. */
.trash-name-cell.type-folder { --tint: var(--type-folder); }
.trash-name-cell.type-link   { --tint: var(--type-link); }
.trash-name-cell.type-text   { --tint: var(--type-text); }
.trash-name-cell.type-doc    { --tint: var(--type-doc); }
.trash-name-cell .icon { color: var(--tint); }
.trash-inside { color: var(--text-dim); font-size: var(--fs-sm); }

/* ---------- Instructions ---------- */

/* The help page is prose plus reference tables, so it is capped at a comfortable reading width
   instead of stretching across a wide screen the way the admin tables do. */
.help-view .help-inner { max-width: 980px; }

.help-lead {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 16px 18px; margin: 0; font-size: var(--fs-md); line-height: 1.65;
  color: var(--text-2);
  box-shadow: var(--shadow-sm);
}

.help-steps { list-style: none; counter-reset: help-step; margin: 0; padding: 0; display: grid; gap: 8px; }
.help-steps li {
  position: relative; padding: 12px 16px 12px 48px; font-size: var(--fs-md); line-height: 1.55;
  color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.help-steps li::before {
  counter-increment: help-step; content: counter(help-step);
  position: absolute; left: 14px; top: 11px; width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink);
  font-size: var(--fs-xs); font-weight: 700;
}
/* Номера шагов идут по кругу теми же четырьмя цветами. */
.help-steps li:nth-child(4n+2)::before { background: var(--c-green-soft);  color: var(--c-green-ink); }
.help-steps li:nth-child(4n+3)::before { background: var(--c-yellow-soft); color: var(--c-yellow-ink); }
.help-steps li:nth-child(4n)::before   { background: var(--c-red-soft);    color: var(--c-red-ink); }

.help-types { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.help-type {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.help-type-head { display: flex; align-items: center; gap: 9px; font-weight: 600; margin-bottom: 5px; }
.help-type-head .icon { width: 19px; height: 19px; vertical-align: 0; color: var(--accent); }
/* Карточка типа повторяет цвет, которым этот тип нарисован в проводнике. Атрибут `data-icon`
   после вставки SVG остаётся в разметке, по нему и красим. */
.help-type-head[data-icon="link"] .icon { color: var(--type-link); }
.help-type-head[data-icon="text"] .icon { color: var(--type-text); }
.help-type-head[data-icon="doc"]  .icon { color: var(--type-doc); }
.help-type { border-top: 3px solid var(--type-folder); }
.help-type:nth-child(2) { border-top-color: var(--type-link); }
.help-type:nth-child(3) { border-top-color: var(--type-text); }
.help-type:nth-child(4) { border-top-color: var(--type-doc); }
.help-type p { margin: 0; font-size: var(--fs-sm); line-height: 1.5; color: var(--text-dim); }

table.help-table td { vertical-align: top; line-height: 1.55; color: var(--text-2); }
table.help-table td:first-child { font-weight: 600; width: 30%; color: var(--text); }
table.help-table td:first-child .icon {
  width: 17px; height: 17px; vertical-align: -3px; margin-right: 9px; color: var(--text-dim);
}
table.help-table code {
  font-family: var(--font-mono); font-size: var(--fs-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 5px;
}
.help-table .badge { margin-left: 6px; vertical-align: 1px; }
/* Специфичность здесь не для красоты: правило `td:first-child` выше задаёт цвет и без
   уточнения `table.help-table` перекрывает одиночный класс. */
.help-danger,
table.help-table td.help-danger { color: var(--danger-ink); }

.help-note { color: var(--text-dim); font-size: var(--fs-sm); line-height: 1.65; margin: 12px 0 0; }
.help-facts { margin: 0; padding-left: 20px; font-size: var(--fs-md); line-height: 1.7; color: var(--text-2); }
.help-facts li { margin-bottom: 4px; }

@media (max-width: 720px) {
  .panel-view { padding: 20px 16px 32px; }
  table.help-table td:first-child { width: 40%; }
  .content-toolbar, .content-grid { padding-left: 14px; padding-right: 14px; }
}

/* ---------- Логи сервера ---------- */

.logs-toolbar {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 18px; flex-wrap: wrap;
}
/* Выбор прошлых отчётов уезжает вправо: это не действие, а навигация по истории. */
.logs-history {
  margin-left: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  color: var(--text-2); font-size: var(--fs-sm); padding: 6px 10px;
  max-width: 100%;
}

/* Итог сверху и карточка раздела красятся одним из четырёх цветов палитры: зелёный —
   спокойно, жёлтый — есть на что посмотреть, красный — требует внимания. Пятого состояния
   у отчёта нет. */
.log-summary {
  border: 1px solid var(--c-green-line); background: var(--c-green-wash);
  border-radius: var(--r-xl); padding: 16px 18px; margin-bottom: 20px;
}
.log-summary-title { font-size: var(--fs-xl); font-weight: 650; color: var(--c-green-ink); }
.log-summary-sub { font-size: var(--fs-sm); color: var(--text-2); margin-top: 4px; }
.log-summary.log-warn { border-color: var(--c-yellow-line); background: var(--c-yellow-wash); }
.log-summary.log-warn .log-summary-title { color: var(--c-yellow-ink); }
.log-summary.log-alert { border-color: var(--c-red-line); background: var(--c-red-wash); }
.log-summary.log-alert .log-summary-title { color: var(--c-red-ink); }

.log-card {
  background: var(--surface);
  border: 1px solid var(--border);
  /* Полоса слева — единственный носитель уровня в карточке: заливать её целиком незачем,
     на экране таких карточек до полутора десятков. */
  border-left: 3px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.log-card.log-warn { border-left-color: var(--c-yellow); }
.log-card.log-alert { border-left-color: var(--c-red); }

.log-card-head { display: flex; align-items: center; gap: 10px; }
.log-card-title { font-size: var(--fs-lg); font-weight: 600; }
.log-count {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  background: var(--surface-3); color: var(--text-2);
  border-radius: 999px; padding: 2px 10px;
  font-size: var(--fs-sm); font-weight: 600;
}
.log-card.log-warn .log-count { background: var(--c-yellow-soft); color: var(--c-yellow-ink); }
.log-card.log-alert .log-count { background: var(--c-red-soft); color: var(--c-red-ink); }
.log-card-desc { margin: 6px 0 0; font-size: var(--fs-sm); color: var(--text-dim); line-height: 1.6; }

.log-sub-title {
  margin: 14px 0 6px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim);
}
.log-sources-title { margin-top: 26px; }

table.data-table.log-stats { box-shadow: none; }
table.data-table.log-stats td { padding: 7px 12px; font-size: var(--fs-sm); }
.log-stat-value { text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; }
.log-source-bad td { color: var(--danger-ink); }

/* Строки журнала — как есть, без переноса слов: перенос посреди адреса или User-Agent
   делает строку нечитаемой. Отсюда своя прокрутка вбок. */
.log-samples {
  margin: 0;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 10px 12px;
  font-family: var(--font-mono); font-size: var(--fs-xs); line-height: 1.6;
  color: var(--text-2);
  overflow-x: auto; white-space: pre;
}

.log-quiet {
  margin: 4px 0 0; font-size: var(--fs-sm); color: var(--text-dim); line-height: 1.7;
}

/* ---------- Notepad ---------- */

.notepad-view { flex: 1; display: flex; flex-direction: column; padding: 26px 32px; min-height: 0; }
.notepad-view h2 { margin: 0 0 14px; font-size: 22px; font-weight: 650; }
.notepad-view textarea {
  flex: 1; resize: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
  color: var(--text); padding: 20px; font-size: var(--fs-lg); line-height: 1.65;
  font-family: var(--font-mono);
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.notepad-view textarea:focus { border-color: var(--accent); box-shadow: var(--ring); }
.notepad-status { margin-top: 10px; font-size: var(--fs-xs); color: var(--text-dim); }

/* ---------- Terminal ---------- */

.terminal-view { flex: 1; display: flex; flex-direction: column; padding: 26px 32px; min-height: 0; }
/* Статус бывает длинным («отключено — закройте вкладку…»), поэтому шапка переносится. */
.terminal-header { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 12px; }
.terminal-header h2 { font-size: 22px; font-weight: 650; }
.terminal-status {
  font-size: var(--fs-xs); color: var(--text-dim);
  padding: 3px 10px; border-radius: 999px; background: var(--surface-3);
}
.terminal-status.connected { color: var(--c-green-ink); background: var(--success-soft); }
.terminal-status.error { color: var(--danger-ink); background: var(--danger-soft); }

/* Полоса вкладок. Одна вкладка — одно WebSocket-соединение и один shell на сервере. */
.terminal-tabs { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; min-width: 0; }
.terminal-tab-strip { display: flex; gap: 4px; min-width: 0; overflow-x: auto; padding-bottom: 2px; }

.terminal-tab {
  display: flex; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding-right: 4px;
  white-space: nowrap; flex-shrink: 0;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.terminal-tab:hover { border-color: var(--border-strong); }
.terminal-tab.active { background: var(--accent-soft); border-color: transparent; }

.terminal-tab-label {
  background: none; border: none; color: var(--text-2);
  font-size: var(--fs-sm); font-weight: 500;
  padding: 7px 4px 7px 12px; border-radius: var(--r-md);
}
.terminal-tab.active .terminal-tab-label { color: var(--accent-ink); font-weight: 600; }

/* Оборвавшаяся сессия помечается точкой на самой вкладке: строка статуса в шапке одна,
   и по ней не понять, какая из вкладок отвалилась. */
.terminal-tab.dead .terminal-tab-label { color: var(--danger-ink); }
.terminal-tab.dead .terminal-tab-label::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--danger); margin-right: 7px; vertical-align: 1px;
}

.terminal-tab-close {
  background: none; border: none; color: var(--text-dim);
  display: flex; align-items: center; padding: 4px; border-radius: var(--r-sm);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.terminal-tab-close .icon { width: 13px; height: 13px; vertical-align: 0; }
.terminal-tab-close:hover { background: var(--overlay-hover-strong); color: var(--danger-ink); }

.terminal-panes { flex: 1; min-height: 0; display: flex; }
.terminal-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
  /* Тёмная подложка — единственное тёмное место в интерфейсе, и это не прихоть:
     цветовые коды ANSI рассчитаны на тёмный фон. Значение продублировано в теме xterm
     в `app.js` и обязано совпадать. */
  background: #12151b;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  padding: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

/* ---------- Toast ---------- */

#toast-container {
  position: fixed; bottom: 22px; right: 22px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  color: var(--text-2);
  padding: 11px 16px; border-radius: var(--r-md); font-size: var(--fs-sm);
  box-shadow: var(--shadow-lg);
  animation: toast-in .16s var(--ease);
}
.toast.error { border-left-color: var(--danger); color: var(--danger-ink); }
.toast.success { border-left-color: var(--success); color: var(--c-green-ink); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- Scrollbars ---------- */

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 6px;
  border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Reduced motion ----------
   Системная настройка «меньше движения» ставится не из эстетики: анимация интерфейса
   вызывает тошноту при вестибулярных расстройствах. Оставляем только исчезающе короткие
   переходы цвета, всё смещение и вращение убираем. */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .item-card:hover { transform: none; }
  .btn:active { transform: none; }
}

/* ---------- Телефон ---------- */

/* Отдельной мобильной вёрстки в проекте нет и заводить её не следует: второй набор разметки
   пришлось бы синхронизировать руками, как вкладку «Инструкция», и он разъехался бы с первым.
   Вместо этого — одна раскладка, которая ниже 640 пикселей перестраивается.

   Кнопка вызова дерева объявлена скрытой здесь же, а не в общем блоке: так всё, что касается
   узкого экрана, читается одним куском. */

.nav-toggle { display: none; }
.nav-backdrop { display: none; }

/* Зелёная точка «сейчас на сайте» в панели управления. Цвет один из четырёх базовых:
   зелёный здесь значит ровно то же, что и везде, — всё в порядке и работает. */
.online-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--c-green);
  vertical-align: middle;
}

/* ---------------- Удалённый доступ ---------------- */

/* Подсказка под полем формы. */
.field-hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-dim);
}

/* Предупреждение о незащищённом соединении: жёлтый — «работает не всё», не ошибка. */
.remote-warn {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid var(--c-yellow-line);
  border-radius: var(--r-lg);
  background: var(--c-yellow-wash);
  color: var(--c-yellow-ink);
  font-size: 13px;
}

.remote-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
}

.remote-status {
  font-size: 13px;
  color: var(--text-2);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remote-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  margin-bottom: 8px;
}

.remote-user-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;              /* overflow:hidden у соседей обнуляет минимальный размер флекс-элемента */
  padding: 7px;
  border-radius: var(--r-md);
  background: var(--c-blue-soft);
  color: var(--c-blue-ink);
}

.remote-user-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Адрес — данные пользователя: он может быть длинным, но не должен распирать строку. */
.remote-user-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remote-user-hint {
  font-size: 12px;
  color: var(--text-dim);
}

.remote-user-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Пояснение в окне согласия: для режима управления оно важнее самой кнопки. */
.remote-ask-note {
  margin: 8px 0 4px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
}

/* Окно согласия на управление — по той же причине, что и полоса ниже: выше контекстного
   меню и подсказок. Общий .modal-overlay сидит на 100 и оказался бы под ними. */
#remote-ask-overlay { z-index: 400; }

/* Полоса запроса на показ экрана — вместо модального окна намеренно. Следом за согласием
   браузер откроет свой диалог доступа к экрану, и окно перед ним было бы вторым окном
   согласия подряд. Кнопка здесь всё равно обязательна: getDisplayMedia() открывается только
   из жеста человека. У режима «Управлять» окно осталось — там второго диалога нет. */
#remote-ask-bar {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  /* Выше всего остального на странице, включая контекстное меню (200) и всплывающие
     подсказки (300). Запрос чужого доступа не должен оказаться под чем бы то ни было:
     невидимый запрос — это либо пропущенный, либо разрешённый вслепую. */
  z-index: 400;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  max-width: min(680px, calc(100vw - 24px));
  padding: 10px 12px 10px 16px;
  background: var(--surface);
  border: 1px solid var(--c-blue-line);
  border-left: 3px solid var(--c-blue);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  animation: toast-in .16s var(--ease);
}
#remote-ask-bar .remote-ask-bar-body { flex: 1 1 260px; min-width: 0; }
#remote-ask-bar .remote-ask-bar-text {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.4;
}
#remote-ask-bar .remote-ask-bar-note {
  margin: 3px 0 0;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.45;
}
#remote-ask-bar .remote-ask-bar-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.remote-stage {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
}

.remote-stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--text-2);
}

.remote-stage-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* В полноэкранном режиме разворачивается контейнер, а не видео: полоса с кнопкой «Завершить»
   остаётся на месте, иначе выйти из чужого экрана можно было бы только клавишей Esc.
   Без явных правил браузер растянет контейнер, а видео останется прежней высоты — отсюда
   flex-колонка и снятое ограничение max-height. Два селектора, а не один через запятую:
   неизвестный псевдокласс в списке отменяет всё правило целиком. */
.remote-stage:fullscreen {
  display: flex;
  flex-direction: column;
  border: 0;
  border-radius: 0;
  background: #000;
}
.remote-stage:fullscreen #remote-video {
  flex: 1;
  min-height: 0;
  max-height: none;
}
.remote-stage:-webkit-full-screen {
  display: flex;
  flex-direction: column;
  border: 0;
  border-radius: 0;
  background: #000;
}
.remote-stage:-webkit-full-screen #remote-video {
  flex: 1;
  min-height: 0;
  max-height: none;
}

/* Чёрная подложка под видео — исключение из палитры, но осознанное: любой другой фон
   виден полосами по краям чужого экрана, пропорции которого мы не знаем заранее. */
#remote-video {
  display: block;
  width: 100%;
  max-height: 70vh;
  background: #000;
  object-fit: contain;
}

/* Реквизиты своего сервера RustDesk. <details>, потому что нужны один раз при настройке
   машины: в каждом сеансе они только занимали бы место над списком людей. */
.remote-server {
  margin: 14px 0;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-2);
}

.remote-server > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}

.remote-server .panel-sub {
  margin: 10px 0;
}

/* Ключ длиннее строки на узком экране — переносим по любому месту, панель не растягиваем. */
.remote-server .remote-rd-row code {
  min-width: 0;
  overflow-wrap: anywhere;
}

.remote-rd-result {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid var(--c-green-line);
  border-radius: var(--r-lg);
  background: var(--c-green-wash);
}

.remote-rd-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
}

.remote-rd-row span {
  min-width: 70px;
  color: var(--text-2);
  font-size: 13px;
}

.remote-rd-row code {
  padding: 4px 10px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 15px;
  user-select: all;            /* реквизиты набирают в другом окне — выделение одним кликом */
}

/* Ряд кнопок под реквизитами: на узком экране переносится, ссылка на веб-клиент выглядит
   такой же кнопкой, как остальные. */
.remote-rd-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

/* Предложение установить RustDesk. Жёлтый, а не красный: это догадка и подсказка, а не
   ошибка — программа вполне может быть на месте, просто фокус не ушёл. */
.remote-rd-missing {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--c-yellow-line);
  border-radius: var(--r-md);
  background: var(--c-yellow-wash);
  font-size: 13px;
  color: var(--text);
}

.remote-rd-missing .remote-rd-actions {
  margin-top: 8px;
}

/* Запасной путь: команда для терминала и объяснение, почему окно могло не открыться.
   Отделён линией, потому что читают его только тогда, когда основной путь не сработал. */
.remote-rd-fallback {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--c-green-line);
  font-size: 13px;
  color: var(--text-2);
}

.remote-rd-fallback code {
  padding: 2px 6px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}

/* Команда длиннее строки — переносим по словам, а не растягиваем панель. */
.remote-rd-fallback .remote-rd-row code {
  flex: 1;
  min-width: 0;
  padding: 4px 10px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  /* Верхняя панель в две строки: логотип с кнопками сверху, вкладки отдельной полосой.
     Пять вкладок в одну строку с логотипом и почтой не помещаются никак. */
  .app-topbar {
    height: auto;
    flex-wrap: wrap;
    align-items: center;
    padding: 8px 10px 0;
    gap: 8px;
  }
  /* Вкладки лежат внутри `.brand`, поэтому переносить их порядком нельзя, пока сам `.brand`
     остаётся отдельной коробкой. `display: contents` растворяет его, и логотип, название и
     полоса вкладок становятся прямыми детьми панели — только тогда вкладки уходят на свою
     строку. Размеры логотипа задаются здесь же: вместе с коробкой пропали и её стили. */
  .app-topbar .brand { display: contents; }
  .app-topbar .brand-icon { width: 26px; height: 26px; }
  .nav-toggle { display: inline-flex; }

  /* Почта — самое ненужное на узком экране: она не действие, а справка, и её видно
     в окне «Аккаунт». */
  .user-email { display: none; }
  .topbar-right { gap: 6px; }
  /* У кнопок остаются значки: подписи «Аккаунт» и «Выход» съедают всю строку. */
  #btn-account { font-size: 0; gap: 0; padding: 7px 9px; }
  #btn-account .icon { margin: 0; }

  /* Вкладки уезжают на свою строку и прокручиваются вбок: их шесть, и на 360 пикселях
     они не уместятся ни при каком размере шрифта. */
  .topbar-right { order: 2; margin-left: auto; }

  .tabs {
    order: 3;
    width: 100%;
    /* Без отрицательных полей: вместе с `width: 100%` они делали строку шире экрана, и по
       горизонтали ехала вся страница, а не одна полоса вкладок. */
    padding: 4px 0 8px;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { flex-shrink: 0; padding: 8px 12px; }

  /* Дерево: из колонки раскладки — в выдвижную панель поверх содержимого. */
  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: min(86vw, 320px);
    z-index: 70;
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform var(--dur) var(--ease);
  }
  .sidebar.open { transform: none; }

  .nav-backdrop {
    display: block;
    position: fixed; inset: 0;
    z-index: 60;
    background: rgba(20, 23, 28, 0.42);
  }

  /* Содержимое занимает всю ширину: соседа по строке у него больше нет. */
  .content-pane { width: 100%; }
  .content-toolbar { padding: 10px 14px; gap: 8px; }

  /* Четыре кнопки создания в столбик съедали 199 пикселей высоты — больше трети экрана.
     Одна строка с прокруткой вбок, как у вкладок. */
  .toolbar-actions {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    width: 100%;
  }
  .toolbar-actions::-webkit-scrollbar { display: none; }
  .toolbar-actions .btn { flex-shrink: 0; }
  .content-grid { padding: 14px; }
  .content-grid.list-mode { padding: 8px 14px 14px; }

  /* Хлебные крошки переносить нельзя — на трёх уровнях вложенности они займут пол-экрана,
     поэтому одна строка с прокруткой вбок. */
  .breadcrumb {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    width: 100%;
  }
  .breadcrumb::-webkit-scrollbar { display: none; }
  .breadcrumb > span { flex-shrink: 0; }

  /* Модалка занимает почти весь экран: поля ввода и текст заметки на 380 пикселях
     нечитаемы, а места вокруг всё равно нет. */
  .modal, .modal.modal-wide {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    padding: 20px 16px;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
  }
  .modal-overlay { align-items: flex-end; }

  /* Таблицы справки и админки шире экрана по своей природе: у файлов четыре колонки,
     у пользователей пять. Режем не содержимое, а полосу прокрутки. */
  .panel-view table { display: block; overflow-x: auto; white-space: nowrap; }
  table.help-table td:first-child { width: auto; }
  .panel-view { padding: 16px 12px 28px; }

  .notepad-view, .terminal-view { padding: 16px 12px; }
}

/* Пальцем в кнопку 26 пикселей не попасть. Правило по указателю, а не по ширине экрана:
   планшет и сенсорный ноутбук тоже про касание, хотя места на них достаточно. */
@media (max-width: 640px) {
  .remote-user { flex-wrap: wrap; }
  .remote-user-main { flex-basis: calc(100% - 46px); }
  .remote-user-actions { width: 100%; }
  .remote-user-actions .btn { flex: 1; }
  #remote-video { max-height: 50vh; }
}

@media (hover: none) and (pointer: coarse) {
  .icon-btn, .tab-btn, .view-mode-btn, .btn-small { min-height: 40px; }
  .tree-row { padding-top: 9px; padding-bottom: 9px; }
  .crumb { padding: 7px 8px; }
}
