:root {
  --accent: #6b5ce7;
  --accent-dark: #5343d9;
  --accent-soft: #efecfd;
  --accent-soft-2: #e2ddfb;
  --ink: #1a1a2e;
  --muted: #9aa0b4;
  --muted-2: #6f7488;
  --line: #eef0f4;
  --line-2: #e8eaf1;
  --bg: #ffffff;
  --bg-soft: #f5f6fa;
  --ok: #1f9d55;
  --radius: 16px;
}

* { box-sizing: border-box; }

/* Атрибут hidden должен побеждать любые display:flex/grid из правил ниже */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden; /* никакой горизонтальной прокрутки на всём сайте */
}

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

.btn, .btn--icon, .link-btn, .dropzone, .file-dl, .user-avatar {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Бренд ---------- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand--big { justify-content: center; margin-bottom: 20px; }
.brand-logo { height: 43px; width: auto; display: block; }
.brand--big .brand-logo { height: 62px; }

/* ---------- Кнопки ---------- */
.btn {
  border: none; border-radius: 12px; font-weight: 700; font-size: 14px;
  padding: 12px 20px; display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none; transition: background 0.15s, color 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-dark); }
.btn--ghost { background: var(--accent-soft); color: var(--accent); }
.btn--ghost:hover { background: var(--accent-soft-2); }
.btn--icon {
  background: transparent; color: var(--muted); padding: 8px; border-radius: 10px;
}
.btn--icon:hover { background: var(--bg-soft); color: var(--ink); }
.link-btn { background: none; border: none; color: var(--accent); font-weight: 600; font-size: 13px; padding: 4px; }
.link-btn:hover { color: var(--accent-dark); }

:focus-visible { outline: 3px solid rgba(107, 92, 231, 0.45); outline-offset: 2px; border-radius: 8px; }

/* ---------- Экран входа ---------- */
.login {
  min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 28px; padding: 40px 20px; text-align: center;
}
.login-card {
  max-width: 460px; width: 100%;
  border: 1px solid var(--line-2); border-radius: 24px;
  padding: 44px 36px; box-shadow: 0 20px 60px rgba(107, 92, 231, 0.08);
}
.login-title { font-size: 26px; font-weight: 800; margin: 8px 0 12px; line-height: 1.25; }
.login-sub { color: var(--muted-2); font-size: 15px; line-height: 1.6; margin: 0 0 28px; }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.qr-img {
  width: 240px; height: 240px; border-radius: 16px;
  border: 1px solid var(--line-2); padding: 10px; background: #fff;
}
.login-status { color: var(--muted-2); font-size: 14px; min-height: 20px; }
.login-status--ok { color: var(--ok); font-weight: 700; }
.login-status--err { color: #c74854; font-weight: 600; }
.login-footer { color: var(--muted); font-size: 13px; }

/* ---------- Модалка (подключение MAX) ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100; padding: 20px;
  background: rgba(26, 26, 46, 0.45);
  display: flex; align-items: center; justify-content: center;
  animation: dk-fade 0.2s ease;
}
.modal-card {
  position: relative; background: #fff; border-radius: 20px;
  padding: 32px 28px; max-width: 360px; width: 100%; text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.modal-close {
  position: absolute; top: 10px; right: 12px;
  background: none; border: none; font-size: 17px; color: var(--muted);
  width: 32px; height: 32px; border-radius: 8px;
}
.modal-close:hover { background: var(--bg-soft); color: var(--ink); }
.modal-title { font-size: 20px; font-weight: 800; }
.modal-sub { font-size: 14px; color: var(--muted-2); margin: 0; line-height: 1.5; }
.max-code { font-size: 13px; color: var(--muted); }
.max-code b { color: var(--ink); font-family: ui-monospace, monospace; letter-spacing: 0.5px; }

/* ---------- Ачивки / звания ---------- */
.rank-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-soft); color: var(--accent);
  border: none; border-radius: 999px; padding: 5px 12px 5px 9px;
  font-family: inherit; font-weight: 800; font-size: 13px;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.rank-badge:hover { background: var(--accent-soft-2); }
.rank-icon { font-size: 15px; line-height: 1; }

.bar-track { height: 12px; background: var(--bg-soft); border-radius: 7px; overflow: hidden; }
.bar-fill {
  height: 100%; width: 0; border-radius: 7px;
  background: linear-gradient(90deg, #6b5ce7, #5343d9);
  transition: width 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.achv-card { max-width: 400px; align-items: stretch; text-align: left; gap: 18px; }
.achv-rank { display: flex; align-items: center; gap: 14px; }
.achv-icon { font-size: 46px; line-height: 1; flex-shrink: 0; }
.achv-rank-label { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.achv-rank-name { font-size: 26px; font-weight: 800; }
.achv-progress-text { font-size: 13px; color: var(--muted-2); margin-bottom: 8px; }
.achv-stats { font-size: 14px; color: var(--muted-2); font-weight: 600; }
.achv-badges-title { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.achv-badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.achv-badge {
  display: flex; flex-direction: column; align-items: center; gap: 5px; text-align: center;
  padding: 12px 6px; border-radius: 12px; background: var(--bg-soft); border: 1px solid var(--line-2);
}
.achv-badge.locked { opacity: 0.4; filter: grayscale(1); }
.achv-badge-icon { font-size: 24px; line-height: 1; }
.achv-badge-name { font-size: 11px; font-weight: 700; line-height: 1.2; }

@media (prefers-reduced-motion: reduce) { .bar-fill { transition: none; } }

/* ---------- Шапка ---------- */
.app { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; height: 68px; border-bottom: 1px solid var(--line);
}
.user { display: flex; align-items: center; gap: 12px; }
.user-avatar {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
}
.user-avatar--initials {
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}
.user-name { font-weight: 700; font-size: 15px; }

/* ---------- Раскладка ---------- */
.layout {
  flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 400px;
  gap: 0; min-height: 0;
}
.center {
  padding: 40px 56px; display: flex; flex-direction: column; align-items: center; gap: 32px;
  overflow-y: auto; min-height: 0; min-width: 0;
}
.side {
  border-left: 1px solid var(--line); padding: 28px 24px;
  display: flex; flex-direction: column; gap: 6px;
  overflow: hidden auto; min-height: 0; /* только вертикальный скролл файлов */
}

/* ---------- Баннер подключения бота ---------- */
.banner {
  width: 100%; max-width: 640px;
  background: linear-gradient(135deg, #f6f4ff, #efecfd);
  border: 1px solid var(--accent-soft-2); border-radius: var(--radius);
  padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.banner-text { display: flex; flex-direction: column; gap: 3px; }
.banner-text strong { font-size: 15px; }
.banner-text span { font-size: 13px; color: var(--muted-2); }

/* ---------- Дропзона ---------- */
.dropzone {
  width: 100%; max-width: 640px; min-height: 340px;
  border: 2px dashed #c9c3f2; border-radius: 28px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: #fff; transition: background 0.2s, border-color 0.2s;
}
.dropzone:hover { border-color: var(--accent); background: #fbfbff; }
.dropzone.dragging { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.busy { opacity: 0.7; pointer-events: none; }
.dropzone-icon {
  width: 100px; height: 100px; border-radius: 50%; background: #fff;
  box-shadow: 0 8px 30px rgba(107, 92, 231, 0.18);
  display: flex; align-items: center; justify-content: center;
  animation: pulse 3s ease-in-out infinite;
}
.dropzone-title { font-size: 26px; font-weight: 800; }
.dropzone-sub { font-size: 15px; color: var(--muted); }

@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

/* Стрелка в облаке непрерывно «взлетает» — приглашает закинуть файл */
@keyframes dz-fly {
  0%   { transform: translateY(3px);  opacity: 0; }
  30%  { transform: translateY(0);    opacity: 1; }
  70%  { transform: translateY(-4px); opacity: 1; }
  100% { transform: translateY(-8px); opacity: 0; }
}
.dz-arrow { animation: dz-fly 1.8s ease-in-out infinite; will-change: transform, opacity; }
.dropzone.dragging .dz-arrow { animation-duration: 0.9s; }

@media (prefers-reduced-motion: reduce) {
  .dropzone-icon { animation: none; }
  .dz-arrow { animation: none; opacity: 1; }
  .btn:active { transform: none; }
}

/* ---------- Тумблер мессенджера ---------- */
.messenger-toggle {
  display: inline-flex; gap: 4px; padding: 4px;
  background: var(--bg-soft); border: 1px solid var(--line-2); border-radius: 14px;
}
.mt-opt {
  display: inline-flex; align-items: center; gap: 8px;
  border: none; background: transparent; color: var(--muted-2);
  font-weight: 700; font-size: 14px; padding: 9px 18px; border-radius: 10px;
  transition: background 0.15s, color 0.15s;
}
.mt-opt:hover:not(:disabled):not(.is-active) { color: var(--ink); }
.mt-opt.is-active { background: #fff; color: var(--accent); box-shadow: 0 2px 8px rgba(107, 92, 231, 0.15); }
.mt-opt:disabled { color: var(--muted); cursor: not-allowed; }
.mt-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.mt-arrow { font-weight: 800; margin-right: -3px; }
.mt-soon {
  font-size: 11px; font-weight: 700; color: #fff; background: var(--muted);
  border-radius: 6px; padding: 1px 6px;
}

/* ---------- Фичи ---------- */
.features { display: flex; gap: 40px; flex-wrap: wrap; justify-content: center; max-width: 700px; }
.feature { display: flex; gap: 12px; align-items: flex-start; max-width: 200px; }
.feature-ico {
  width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.feature-title { font-weight: 800; font-size: 15px; }
.feature-sub { font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.45; }

/* ---------- Список файлов ---------- */
.side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.side-title { font-size: 19px; font-weight: 800; }
.files { display: flex; flex-direction: column; }
.file {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 6px; border-bottom: 1px solid #f2f3f7;
}
.file-ext {
  width: 40px; height: 40px; border-radius: 10px; color: #fff; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800;
}
.file-main { flex: 1; min-width: 0; }
.file-name {
  font-weight: 700; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.dir { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; }
.dir--out { color: var(--accent); }
.dir--in { color: var(--ok); }
.file-dl {
  color: var(--muted); background: none; border: none; padding: 6px; border-radius: 8px; flex-shrink: 0;
  display: flex;
}
.file-dl:hover { color: var(--accent); background: var(--accent-soft); }
.files-empty { color: var(--muted); font-size: 14px; padding: 24px 6px; text-align: center; }

/* Пачка файлов (пришли/отправлены вместе) */
.file-batch {
  border: 1px solid var(--line-2);
  border-radius: 12px;
  margin: 6px 0;
  overflow: hidden;
}
.batch-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; background: var(--bg-soft);
}
.batch-title { font-size: 12.5px; font-weight: 700; color: var(--muted-2); }
.batch-dl {
  font-size: 12.5px; font-weight: 800; color: var(--accent);
  white-space: nowrap; touch-action: manipulation;
}
.batch-dl:hover { color: var(--accent-dark); }
.batch-dl.disabled { color: var(--muted); pointer-events: none; }
.batch-files { padding: 0 8px; }
.batch-files .file:last-child { border-bottom: none; }

/* Стойкое выделение непрочитанного (нового) файла */
.file.is-unseen {
  box-shadow: inset 3px 0 0 var(--accent);
  background: linear-gradient(90deg, rgba(107, 92, 231, 0.08), transparent 55%);
  border-radius: 8px;
  cursor: pointer;
}
.tag-new {
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 800; letter-spacing: 0.2px;
  padding: 1px 6px; border-radius: 5px;
}

/* Файл в процессе загрузки на сервер */
@keyframes dk-spin { to { transform: rotate(360deg); } }
.file-spin {
  width: 18px; height: 18px; flex-shrink: 0;
  border: 2px solid var(--accent-soft-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: dk-spin 0.7s linear infinite;
}
.file.is-loading .file-name { color: var(--muted-2); }
.file.is-loading .file-ext { opacity: 0.55; }
@media (prefers-reduced-motion: reduce) { .file-spin { animation: none; } }

/* ---------- Тост ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px;
  font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  z-index: 50; max-width: 90vw;
}
.toast--err { background: #c74854; }
.toast--ok { background: var(--ok); }

/* ---------- Анимации ---------- */
@keyframes dk-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes dk-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes dk-flash {
  0% { background: var(--accent-soft); }
  100% { background: transparent; }
}
@keyframes dk-toast {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.app, .login { animation: dk-fade 0.35s ease both; }
.center > * { animation: dk-up 0.45s ease both; }
.center > *:nth-child(2) { animation-delay: 0.06s; }
.center > *:nth-child(3) { animation-delay: 0.12s; }
.center > *:nth-child(4) { animation-delay: 0.18s; }
.side { animation: dk-up 0.5s ease both; animation-delay: 0.08s; }
.file.is-new { animation: dk-flash 2.4s ease-out; }
.toast { animation: dk-toast 0.25s ease; }

@media (prefers-reduced-motion: reduce) {
  .app, .login, .center > *, .side, .file.is-new, .toast { animation: none !important; }
}

/* ---------- Адаптив ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { border-left: none; border-top: 1px solid var(--line); }
  .center { padding: 28px 20px; }
  .header { padding: 0 20px; }
  /* на мобильном — обычный скролл страницы, без фиксации высоты */
  .app { height: auto; overflow: visible; }
  .center, .side { overflow: visible; min-height: 0; }
}
