:root {
  --bg: #141414;
  --panel: #1e1e1e;
  --panel2: #242424;
  --line: #2e2e2e;
  --text: #d6d6d6;
  --muted: #8a8a8a;
  --accent: #9a9a9a;
  --danger: #b5655a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Segoe UI", system-ui, sans-serif;
  padding: 32px max(24px, (100vw - 1100px)/2);
}

.brand { font-size: 20px; font-weight: 600; letter-spacing: .5px; }
.brand span { color: var(--muted); font-weight: 400; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px;
  gap: 12px;
}

.btn {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 18px; cursor: pointer; font-size: 13px;
  transition: background .15s;
}
.btn:hover { background: var(--accent); color: #101010; }
.btn.prime { background: var(--accent); color: #101010; border-color: transparent; }
.btn.prime:hover { background: #b5b5b5; }

/* list */
.list { margin-top: 22px; display: flex; flex-direction: column; gap: 6px; }
.list-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
}
.list-item .ic {
  width: 30px; height: 30px; border-radius: 6px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; font-size: 13px;
  background: var(--panel2); color: var(--muted); font-weight: 700;
}
.ic.text  { background: #3a3a3a; color: #cfcfcf; }
.ic.video { background: #423d3a; color: #e0b0a0; }
.ic.image { background: #3a4038; color: #b8c0a8; }

.list-item .name { flex: 1; font-weight: 600; word-break: break-word; }
.list-item .meta { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* режим выделения (двойной ПКМ): кружки слева, кнопки строк скрыты */
.sel-dot {
  width: 18px; height: 18px; border-radius: 50%; flex: 0 0 auto;
  border: 2px solid var(--muted); cursor: pointer; display: none;
}
.list-item.in-select .sel-dot { display: block; }
.list-item.in-select.selected .sel-dot { background: #7fae72; border-color: #7fae72; }
.list-item.in-select.selected { border-color: #7fae72; }
.list-item.in-select .actions { display: none; }
.list-item.in-select { cursor: pointer; user-select: none; }

.actions { display: flex; gap: 6px; }
.act {
  border: 1px solid var(--line); background: transparent; color: var(--text);
  border-radius: 5px; padding: 6px 10px; font-size: 12px; cursor: pointer;
  transition: background .15s;
}
.act:hover { background: var(--panel2); }
.act.danger:hover { background: var(--danger); color: #fff; }

.empty { color: var(--muted); text-align: center; padding: 60px 0; font-size: 13px; }

/* overlays */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10,10,10,.85);
  display: flex; align-items: center; justify-content: center;
}
.overlay.hidden { display: none; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  width: min(900px, 94vw); max-height: 88vh; display: flex; flex-direction: column;
  overflow: hidden;
}
.panel-actions { display: flex; gap: 8px; align-items: center; }
.panel-head {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); background: var(--panel2);
}
.edit-title {
  background: transparent; border: 1px solid var(--line); border-radius: 6px;
  color: var(--text); font-size: 14px; font-weight: 600; padding: 6px 10px; flex: 1;
}
.edit-body {
  width: 100%; background: var(--panel); color: var(--text);
  border: none; resize: none; font-family: "Consolas", ui-monospace, monospace;
  font-size: 13px; line-height: 1.5; padding: 16px; flex: 1; min-height: 300px;
  outline: none;
}
.video-frame { width: 100%; background: #000; }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 8px; font-size: 13px; z-index: 100;
  display: flex; align-items: center; gap: 8px;
  max-width: min(560px, 92vw); line-height: 1.45;
}
.toast.hidden { display: none; }
.toast-ic {
  width: 18px; height: 18px; border-radius: 50%; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #101010;
}
.toast-ic.ok { background: #7fae72; }
.toast-ic.err { background: #b5655a; }
.toast-ic.warn { background: #d8b45c; }

.topbar-right { display: flex; align-items: center; gap: 10px; }

/* login page */
body.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}

/* media viewer */
.viewer-panel { width: min(1100px, 96vw); max-height: 92vh; }
.viewer-title { font-weight: 600; word-break: break-all; flex: 1; }
.viewer-stage {
  position: relative; background: #0a0a0a; display: flex; flex-direction: column;
  align-items: center; justify-content: center; min-height: 200px;
}
.video-frame { width: 100%; max-height: 74vh; background: #000; }
.image-frame {
  max-width: 100%; max-height: 80vh; object-fit: contain; display: block; margin: 0 auto;
}
.vp-controls {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: rgba(20,20,20,.92); box-sizing: border-box;
  border-top: 1px solid var(--line);
}
.vp-btn {
  background: transparent; border: none; color: var(--text); cursor: pointer;
  font-size: 15px; padding: 4px 8px; border-radius: 5px;
}
.vp-btn:hover { background: var(--panel2); }
.vp-time { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.vp-progress {
  flex: 1; height: 6px; background: #333; border-radius: 3px; cursor: pointer;
  position: relative;
}
.vp-progress:hover { height: 8px; }
.vp-fill {
  height: 100%; width: 0; background: var(--accent); border-radius: 3px;
}
.vp-vol { width: 80px; accent-color: var(--accent); }
.vp-speed {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 5px; font-size: 12px; padding: 4px;
}

/* tabs / pages */
.tabs { display: flex; gap: 4px; }
.tab {
  background: transparent; color: var(--muted); border: 1px solid transparent;
  border-radius: 6px; padding: 8px 14px; font-size: 13px; cursor: pointer;
  text-decoration: none; display: inline-block;
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); background: var(--panel2); }
.tab.active { color: var(--text); background: var(--panel2); border-color: var(--line); }
.whoami {
  display: flex; align-items: center; gap: 8px;
  color: #fff; font-weight: 700; font-size: 13px; white-space: nowrap;
}
.ava {
  width: 22px; height: 22px; border-radius: 50%; object-fit: cover;
  flex: 0 0 auto; border: 1px solid var(--line);
}

.dropzone {
  margin-top: 12px; padding: 10px 20px; text-align: center;
  font-size: 12px; color: var(--muted);
  background: var(--panel); border: 1px dashed var(--line); border-radius: 10px;
}
.page { }

/* users page */
.role-badge {
  font-size: 11px; font-weight: 700; border-radius: 4px; padding: 2px 8px;
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
}
.role-badge.admin { color: #e0b0a0; border-color: #6a4a42; }
.role-badge.moderator { color: #b8c0a8; border-color: #4a5240; }

/* login */
.login-panel {
  width: min(340px, 92vw); padding: 24px 20px;
  display: flex; flex-direction: column; gap: 12px; align-items: stretch;
}
.login-title {
  font-size: 20px; font-weight: 700; text-align: center;
  letter-spacing: 1.5px;
}
.login-title .dim { color: var(--muted); font-weight: 400; }
.login-sub { color: var(--muted); font-size: 12px; text-align: center; }
.login-code { flex: none; text-align: center; font-size: 16px; letter-spacing: 2px; }
.login-btn { align-self: stretch; }
.login-err { color: var(--danger); font-size: 12px; text-align: center; }
.login-divider {
  display: flex; align-items: center; gap: 10px; margin: 2px 0;
}
.login-divider::before, .login-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--line); opacity: .6;
}
.login-divider span { color: var(--muted); font-size: 11px; letter-spacing: 2px; }

.discord-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: #5865F2; color: #fff; border-color: transparent; font-weight: 600;
}
.discord-btn:hover { background: #4752c4; color: #fff; }

.hidden { display: none; }

/* окно очереди загрузки (внизу по центру) */
.upbar {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%);
  width: min(560px, 92vw);
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 16px; z-index: 90;
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,.45);
}
.upbar.hidden { display: none; }
.upbar-head { display: flex; align-items: center; gap: 10px; }
.upbar-name {
  flex: 1; font-weight: 600; font-size: 13px; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.upbar-count { color: var(--muted); font-size: 12px; white-space: nowrap; }
.upbar-track {
  height: 8px; background: #333; border-radius: 4px; overflow: hidden;
}
.upbar-fill {
  height: 100%; width: 0; background: #7fae72; border-radius: 4px;
  transition: width .2s linear;
}
.upbar-meta {
  display: flex; align-items: center; gap: 14px;
  color: var(--muted); font-size: 12px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.upbar-meta #upbar-percent { color: var(--text); font-weight: 600; }

/* выпадающий список доступа к файлу */
.vis-select {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 5px; font-size: 12px; padding: 5px 6px; cursor: pointer;
}
.vis-select:hover { border-color: var(--accent); }

/* 'Только мне' — жёлтая подсветка строки */
.list-item.self-private {
  background: rgba(255, 214, 102, .07);
  border-color: rgba(255, 214, 102, .38);
}

/* текстовый просмотр (только чтение) */
.vt-frame {
  width: 100%; max-height: 78vh; margin: 0; overflow: auto;
  background: var(--panel); color: var(--text);
  font-family: "Consolas", ui-monospace, monospace;
  font-size: 13px; line-height: 1.5; padding: 16px;
  white-space: pre-wrap; word-break: break-word;
  user-select: text; cursor: text;
}