/* Общая тема для index.html и browse.html.
   Страницы ошибок (404/50x) намеренно автономны и сюда не смотрят. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #0b0d13;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-hover: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e8eaf0;
  --text-dim: #8b90a0;
  --text-faint: #5c6070;
  --accent: #6366f1;
  --accent-hi: #818cf8;
  --ok: #22c55e;
  --radius: 14px;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
  padding: clamp(16px, 5vw, 64px) clamp(12px, 4vw, 32px);
  overflow-x: hidden;
}

/* Мягкое свечение на фоне */
body::before {
  content: "";
  position: fixed;
  inset: -40vmax;
  z-index: -1;
  background:
    radial-gradient(40vmax 40vmax at 22% 12%, rgba(99, 102, 241, 0.16), transparent 60%),
    radial-gradient(34vmax 34vmax at 82% 78%, rgba(217, 70, 239, 0.12), transparent 60%),
    radial-gradient(30vmax 30vmax at 62% 4%, rgba(14, 165, 233, 0.1), transparent 60%);
  filter: blur(12px);
  animation: drift 24s ease-in-out infinite alternate;
}

@keyframes drift {
  to {
    transform: translate3d(2%, -2%, 0) scale(1.08);
  }
}

.app {
  width: 100%;
  max-width: 780px;
  animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

/* ---------- Шапка ---------- */

header {
  margin-bottom: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  flex: none;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  color: #fff;
  border-radius: 13px;
  background: linear-gradient(140deg, var(--accent), #a855f7);
  box-shadow:
    0 8px 24px -8px rgba(99, 102, 241, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.brand-mark svg {
  width: 23px;
  height: 23px;
}

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 4vw, 1.7rem);
  font-weight: 650;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 0.875rem;
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  animation: pulse 2.4s ease-out infinite;
  vertical-align: 1px;
}

@keyframes pulse {
  70%,
  100% {
    box-shadow: 0 0 0 7px rgba(34, 197, 94, 0);
  }
}

/* ---------- Главное меню ---------- */

.hero {
  margin-bottom: 26px;
  text-align: center;
}

.hero .brand-mark {
  width: 62px;
  height: 62px;
  margin: 0 auto 18px;
  border-radius: 18px;
}

.hero .brand-mark svg {
  width: 30px;
  height: 30px;
}

.hero h1 {
  font-size: clamp(1.6rem, 5vw, 2.1rem);
}

.menu {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.tile {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 20px;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition:
    transform 0.18s cubic-bezier(0.22, 1, 0.36, 1),
    background 0.18s,
    border-color 0.18s;
}

a.tile:hover,
a.tile:focus-visible {
  transform: translateY(-3px);
  background: var(--surface-hover);
  border-color: var(--border-strong);
  outline: none;
}

.tile-icon {
  flex: none;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  color: #fff;
  border-radius: 13px;
  background: linear-gradient(140deg, var(--c1, var(--accent)), var(--c2, #a855f7));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.tile-icon svg {
  width: 22px;
  height: 22px;
}

.tile-body {
  flex: 1 1 auto;
  min-width: 0;
}

.tile-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.tile-desc {
  margin-top: 2px;
  font-size: 0.83rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.tile-arrow {
  flex: none;
  color: var(--text-faint);
  transition:
    transform 0.18s,
    color 0.18s;
}

.tile-arrow svg {
  width: 18px;
  height: 18px;
  display: block;
}

a.tile:hover .tile-arrow {
  transform: translateX(3px);
  color: var(--accent-hi);
}

/* ---------- Навигация назад ---------- */

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  padding: 6px 12px 6px 9px;
  font-size: 0.83rem;
  color: var(--text-dim);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  transition:
    color 0.15s,
    background 0.15s;
}

.back:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.back svg {
  width: 15px;
  height: 15px;
}

/* ---------- Панель со списком ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: hidden;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.search {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.search svg {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-faint);
  pointer-events: none;
}

input[type="search"] {
  width: 100%;
  padding: 11px 14px 11px 38px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  outline: none;
  transition:
    border-color 0.18s,
    background 0.18s,
    box-shadow 0.18s;
}

input[type="search"]::placeholder {
  color: var(--text-faint);
}

input[type="search"]:focus {
  background: var(--surface-hover);
  border-color: rgba(129, 140, 248, 0.55);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.14);
}

input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.sort {
  flex: none;
  display: flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
}

.sort button {
  padding: 0 13px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-dim);
  background: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition:
    color 0.18s,
    background 0.18s;
}

.sort button:hover {
  color: var(--text);
}

.sort button[aria-pressed="true"] {
  color: var(--text);
  background: rgba(255, 255, 255, 0.09);
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 6px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 11px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
  animation: fade 0.35s ease both;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
}

.file-item:hover,
.file-item:focus-visible {
  background: var(--surface-hover);
  outline: none;
}

.file-item:focus-visible {
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.icon {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #fff;
  border-radius: 10px;
  background: linear-gradient(140deg, var(--c1), var(--c2));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.icon.dir svg {
  width: 19px;
  height: 19px;
}

.info {
  flex: 1 1 auto;
  min-width: 0;
}

.name {
  font-size: 0.92rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta {
  margin-top: 1px;
  font-size: 0.78rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.action {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--text-faint);
  border-radius: 9px;
  transition:
    color 0.15s,
    background 0.15s,
    transform 0.15s;
}

.action svg {
  width: 17px;
  height: 17px;
}

.file-item:hover .action {
  color: var(--accent-hi);
  background: rgba(99, 102, 241, 0.14);
}

.file-item:hover .action.dl {
  transform: translateY(1px);
}

/* ---------- Состояния ---------- */

.state {
  padding: 46px 24px;
  text-align: center;
  color: var(--text-dim);
}

.state .big svg {
  width: 34px;
  height: 34px;
  margin-bottom: 10px;
  opacity: 0.45;
}

.state code {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 9px;
  font-size: 0.8rem;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 7px;
}

.skeleton {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 11px 12px;
}

.sk {
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.1) 37%,
    rgba(255, 255, 255, 0.05) 63%
  );
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

@keyframes shimmer {
  to {
    background-position: -135% 0;
  }
}

.sk-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex: none;
}

.sk-line {
  height: 9px;
}

/* ---------- Подвал ---------- */

footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 0 4px;
  font-size: 0.78rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 560px) {
  .toolbar {
    flex-wrap: wrap;
  }
  .sort {
    width: 100%;
  }
  .sort button {
    flex: 1;
    padding: 7px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before {
    animation: none !important;
    transition: none !important;
  }
}
