:root {
  --bg: #111214; --panel: #1b1d21; --panel2: #24272c; --line: #2e3238;
  --text: #e8e9ec; --muted: #8b9099; --accent: #4c8dff; --err: #ff6b6b;
  --r: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
code { background: var(--panel2); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.muted { color: var(--muted); }
.err { color: var(--err); min-height: 1.4em; margin: 8px 0 0; }

.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 14px; cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-block; }
.btn:hover { border-color: #444a52; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.big { padding: 14px 18px; font-size: 16px; width: 100%; }
.btn.small { padding: 5px 10px; font-size: 14px; }
.btn.icon { padding: 8px 12px; font-size: 18px; line-height: 1; }

/* вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-box { width: 100%; max-width: 340px; text-align: center; }
.logo { font-size: 54px; }
.login h1 { margin: 4px 0 26px; font-weight: 600; }
#pw-form { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
input[type=password], input[type=search], input[type=text], select {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; outline: none; }
input:focus, select:focus { border-color: var(--accent); }

/* шапка */
.top { position: sticky; top: 0; z-index: 5; display: flex; gap: 10px; align-items: center;
  padding: 10px max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
  background: rgba(17,18,20,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { color: var(--text); text-decoration: none; font-weight: 600; font-size: 17px; white-space: nowrap; }
#search { flex: 1; min-width: 0; }
.menu { position: absolute; right: 14px; top: 54px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 6px; display: flex; flex-direction: column; min-width: 210px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.menu button { background: none; border: 0; text-align: left; padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--panel2); }

.crumbs { padding: 12px 16px 2px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 16px; }
.crumbs a { color: var(--text); text-decoration: none; padding: 2px 6px; border-radius: 6px; }
.crumbs a:hover { background: var(--panel2); }
.crumbs .sep { color: var(--muted); }
.bar { display: flex; justify-content: space-between; align-items: center; padding: 6px 16px 10px; }
.bar select { padding: 5px 8px; font-size: 14px; }

/* плитка */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px;
  padding: 0 16px calc(30px + env(safe-area-inset-bottom)); }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
  cursor: pointer; display: flex; flex-direction: column; min-width: 0; }
.tile:hover { border-color: #444a52; }
.thumb { aspect-ratio: 1; display: grid; place-items: center; background: var(--panel2); font-size: 44px;
  position: relative; overflow: hidden; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; position: absolute; inset: 0; }
.thumb .play { text-shadow: 0 2px 8px rgba(0,0,0,.7); color: #fff; }
.thumb .play { position: absolute; inset: 0; display: grid; place-items: center; font-size: 40px; }
.meta { padding: 7px 9px 9px; }
.name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* список */
.rows { display: flex; flex-direction: column; padding: 0 16px 30px; }
.rows .tile { flex-direction: row; align-items: center; border-radius: 0; border-width: 0 0 1px; background: none; }
.rows .thumb { width: 44px; height: 44px; aspect-ratio: auto; font-size: 22px; border-radius: 8px; flex: none; margin: 6px 0; }
.rows .thumb .play { font-size: 18px; }
.rows .meta { flex: 1; min-width: 0; display: flex; gap: 12px; align-items: center; }
.rows .name { flex: 1; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; grid-column: 1 / -1; }

/* просмотр */
.viewer { position: fixed; inset: 0; background: #000; z-index: 20; display: flex; align-items: center; justify-content: center; }
.v-top { position: absolute; top: 0; left: 0; right: 0; display: flex; gap: 8px; align-items: center; z-index: 2;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px; background: linear-gradient(rgba(0,0,0,.75), transparent); }
#v-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-body { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.v-body img, .v-body video { max-width: 100%; max-height: 100%; }
.v-body video { width: 100%; height: 100%; }
.v-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.v-body .other { text-align: center; color: var(--muted); }
.v-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; background: rgba(255,255,255,.08);
  border: 0; color: #fff; font-size: 34px; width: 46px; height: 70px; border-radius: 10px; cursor: pointer; }
.v-nav.prev { left: 8px; } .v-nav.next { right: 8px; }

/* окна */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 30; display: grid; place-items: center; padding: 16px; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; width: 100%; max-width: 440px; }
.modal-box h2 { margin: 0 0 8px; font-size: 19px; }
.pk-list { list-style: none; padding: 0; margin: 14px 0; }
.pk-list li { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.pk-list li span { flex: 1; }
.modal-box .btn { margin: 4px 6px 0 0; }

/* загрузки */
.drop { position: fixed; inset: 10px; border: 3px dashed var(--accent); border-radius: 18px; z-index: 15;
  background: rgba(76,141,255,.12); display: grid; place-items: center; font-size: 22px; pointer-events: none; }
.uploads { position: fixed; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 12;
  width: min(360px, calc(100vw - 28px)); max-height: 50vh; overflow: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.up { font-size: 13px; padding: 5px 0; }
.up .bar2 { height: 4px; background: var(--panel2); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.up .bar2 i { display: block; height: 100%; background: var(--accent); width: 0; }
.up.done .bar2 i { background: #3ecf8e; } .up.fail { color: var(--err); }

@media (max-width: 560px) {
  .brand span { display: none; }
  .grid { grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 0 4px 30px; }
  .grid .meta { display: none; }
  .grid .tile { border-radius: 4px; border: 0; }
  .grid .tile.folder .meta, .grid .tile.doc .meta { display: block; }
  .v-nav { display: none; }
}
