:root {
  --bg: #f4f5f7; --card: #fff; --text: #1d2330; --muted: #6b7280; --line: #e6e8ec;
  --accent: #2f6fed; --accent-2: #e8efff; --danger: #d93b3b; --hover: #f5f7fb; --ok: #1f9d55;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318; --card: #1a1d24; --text: #e6e8ee; --muted: #9098a8; --line: #2a2f39;
    --accent: #5b8cff; --accent-2: #1f2a44; --danger: #ff6b6b; --hover: #20242d; --ok: #3ecf7e;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
h2 { margin: 0; font-size: 18px; }
input, select, textarea { font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

.btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.x { border: 0; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 2px 8px; }
.x:hover { color: var(--text); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.brand.big { font-size: 22px; justify-content: center; margin-bottom: 8px; }
.logo { color: var(--accent); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.err { color: var(--danger); min-height: 1em; font-size: 13px; }

/* header */
.top { display: flex; align-items: center; gap: 24px; padding: 10px 24px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs a { color: var(--muted); padding: 6px 12px; border-radius: 8px; }
.tabs a:hover { background: var(--hover); color: var(--text); }
.tabs a.active { background: var(--accent-2); color: var(--accent); font-weight: 600; }
.me { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.me #meName { margin-right: 6px; }

main { max-width: 1200px; margin: 0 auto; padding: 20px 24px 60px; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 13px; }

.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; font-size: 16px; }
.crumbs a { color: var(--text); padding: 4px 6px; border-radius: 6px; }
.crumbs a:hover { background: var(--hover); }
.crumbs a:last-child { font-weight: 600; }
.crumbs .sep { color: var(--muted); }

/* tables */
.list { width: 100%; border-collapse: collapse; }
.list th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; text-transform: uppercase;
  letter-spacing: .03em; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.list td { padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list tr:last-child td { border-bottom: 0; }
.list tbody tr:hover { background: var(--hover); }
.list tr.drop-hover { background: var(--accent-2); }
.c-size { width: 110px; } .c-date { width: 160px; } .c-who { width: 130px; } .c-act { width: 1%; }
td.num, td.muted { color: var(--muted); white-space: nowrap; }
.name { display: flex; align-items: center; gap: 10px; cursor: pointer; word-break: break-word; }
.name:hover span.n { color: var(--accent); }
.ico { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; font-size: 11px;
  font-weight: 700; flex: none; background: var(--hover); color: var(--muted); }
.ico.dir { background: #fff3d6; color: #c98a00; font-size: 16px; }
.ico.img { background: #e3f6ec; color: #1f9d55; } .ico.vid { background: #fde8ef; color: #d6336c; }
.ico.doc { background: #e8efff; color: #2f6fed; } .ico.arc { background: #f1e8ff; color: #7c3aed; }
@media (prefers-color-scheme: dark) {
  .ico.dir { background: #3a3120; } .ico.img { background: #17332a; } .ico.vid { background: #3a1d28; }
  .ico.doc { background: #1f2a44; } .ico.arc { background: #2c2140; }
}
.row-act { display: flex; gap: 2px; opacity: .55; }
tr:hover .row-act { opacity: 1; }
.row-act button { border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 6px;
  padding: 5px 7px; font-size: 13px; white-space: nowrap; }
.row-act button:hover { background: var(--line); color: var(--text); }
.row-act button.del:hover { color: var(--danger); }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-ico { font-size: 34px; margin-bottom: 8px; }
.more { text-align: center; padding: 10px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; background: var(--hover); color: var(--muted); }
.tag.upload, .tag.mkdir, .tag.restore { background: #e3f6ec; color: #1f7a45; }
.tag.edit, .tag.replace, .tag.rename { background: #e8efff; color: #2f5fcf; }
.tag.delete, .tag.purge, .tag.user_delete { background: #fde8e8; color: #c02d2d; }
@media (prefers-color-scheme: dark) {
  .tag.upload, .tag.mkdir, .tag.restore { background: #17332a; color: #5fd896; }
  .tag.edit, .tag.replace, .tag.rename { background: #1f2a44; color: #8fb0ff; }
  .tag.delete, .tag.purge, .tag.user_delete { background: #3a1d1d; color: #ff8a8a; }
}
.log td { font-size: 13px; }
.log a.path { word-break: break-all; }
.filters input { width: 200px; }

.inline-form { display: flex; gap: 8px; padding: 12px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.inline-form input { flex: 1; min-width: 160px; }

/* dropzone */
.dropzone { position: fixed; inset: 0; background: rgba(47,111,237,.12); border: 3px dashed var(--accent);
  z-index: 50; display: grid; place-items: center; pointer-events: none; }
.dropzone div { background: var(--card); padding: 18px 26px; border-radius: 12px; font-size: 16px; box-shadow: 0 10px 30px rgba(0,0,0,.15); }

/* uploads */
.uploads { position: fixed; right: 18px; bottom: 18px; width: 360px; max-height: 50vh; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.15); z-index: 40; }
.uploads-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--line); font-weight: 600; }
.uploads-list { overflow: auto; padding: 6px 0; }
.up { padding: 6px 16px; font-size: 13px; }
.up .row { display: flex; justify-content: space-between; gap: 8px; }
.up .fn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up .st { color: var(--muted); flex: none; }
.up .st.ok { color: var(--ok); } .up .st.bad { color: var(--danger); }
.prog { height: 3px; background: var(--line); border-radius: 3px; margin-top: 4px; overflow: hidden; }
.prog i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(10,14,22,.55); z-index: 60; display: grid; place-items: center; padding: 20px; }
.modal-box { background: var(--card); border-radius: 14px; width: min(1100px, 100%); max-height: calc(100vh - 40px);
  display: flex; flex-direction: column; overflow: hidden; }
.modal-box.small { width: min(420px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--line); }
.modal-title { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-actions { display: flex; gap: 6px; }
.modal-body { overflow: auto; flex: 1; min-height: 0; }
.modal-body.pad { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-body.pad label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; }
.preview { display: grid; place-items: center; background: #0b0d12; min-height: 300px; }
.preview img, .preview video { max-width: 100%; max-height: calc(100vh - 120px); display: block; }
.preview audio { width: 80%; margin: 40px; }
.preview iframe { width: 100%; height: calc(100vh - 120px); border: 0; background: #fff; }
.editor { width: 100%; height: calc(100vh - 130px); border: 0; border-radius: 0; resize: none; padding: 16px;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; tab-size: 4; background: var(--card); }
.nopreview { padding: 60px 20px; text-align: center; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1d2330; color: #fff;
  padding: 10px 18px; border-radius: 10px; z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: 90vw; }
.toast.bad { background: var(--danger); }

@media (max-width: 760px) {
  .top { flex-wrap: wrap; gap: 8px; padding: 10px 16px; }
  .brand { flex: 1; }
  .me #meName { display: none; }
  .tabs { order: 3; flex: 1 0 100%; overflow-x: auto; }
  .row-act { flex-wrap: wrap; justify-content: flex-end; width: 120px; opacity: 1; }
  .row-act button { padding: 3px 6px; font-size: 12px; }
  .name { min-width: 120px; }
  .c-size { width: auto; }
  main { padding: 16px; }
  .c-date, .c-who, td.hide-m, th.hide-m { display: none; }
  .list td, .list th { padding: 8px; }
  .uploads { left: 12px; right: 12px; width: auto; }
  .filters input { width: 100%; }
}

/* выбор, меню, перемещение */
.c-chk { width: 1%; padding-right: 0 !important; }
.chk, #chkAll { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
.list tr.sel { background: var(--accent-2); }
.row-btns { display: flex; gap: 4px; justify-content: flex-end; }
.row-btns .btn.sm { padding: 4px 10px; }
.row-btns .more { font-size: 18px; line-height: 1; padding: 2px 10px; letter-spacing: 1px; }
.selbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--accent-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; }
.selbar #selCount { font-weight: 600; margin-right: 6px; }
.menu { position: fixed; z-index: 70; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.15); padding: 4px; min-width: 210px; display: flex; flex-direction: column; }
.menu button { text-align: left; border: 0; background: transparent; color: var(--text); font: inherit; padding: 8px 12px; border-radius: 6px; cursor: pointer; }
.menu button:hover { background: var(--hover); }
.menu button.del { color: var(--danger); }
.crumbs a.drop-hover { background: var(--accent-2); outline: 2px dashed var(--accent); }
tr.drop-hover { outline: 2px dashed var(--accent); outline-offset: -2px; }
.drag-ghost { position: fixed; top: -100px; left: 0; background: var(--accent); color: #fff; padding: 6px 12px; border-radius: 8px; font-size: 13px; }
.picker { display: flex; flex-direction: column; }
.picker .crumbs.small { font-size: 14px; padding: 12px 16px 8px; border-bottom: 1px solid var(--line); }
.picker .crumbs a { cursor: pointer; }
.picker-list { max-height: 50vh; overflow: auto; padding: 6px; min-height: 120px; }
.picker-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.picker-item:hover { background: var(--hover); }
.picker-item.bad { opacity: .45; cursor: not-allowed; }
.picker-item .ico { width: 26px; height: 26px; font-size: 14px; }
.pad { padding: 12px 16px; }
.modal-foot.pad { border-top: 1px solid var(--line); align-items: center; }
@media (max-width: 760px) {
  .row-btns .btn.sm:not(.more) { font-size: 12px; padding: 3px 8px; }
}
.picker .modal-foot { gap: 6px; flex-wrap: nowrap; justify-content: flex-start; }
.modal-box.small:has(.picker) { width: min(540px, 100%); }
@media (max-width: 500px) { .picker .modal-foot { flex-wrap: wrap; } }
.picker .modal-foot .btn { padding: 6px 12px; }
