:root {
  --bg: #1a1b1e;
  --panel: #232428;
  --panel-2: #2b2d31;
  --line: #3a3c42;
  --text: #f2f3f5;
  --muted: #9ea1a8;
  --accent: #5865f2;
  --accent-hover: #6d79f5;
  --danger: #ed4245;
  --ok: #3ba55d;
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

.muted { color: var(--muted); }
.center { text-align: center; }
.spacer { flex: 1; }

/* ---------- barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px;
  background: rgba(26, 27, 30, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 19px; }
.brand p { margin: 0; font-size: 13px; }
.brand-mark {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 15px;
}
.tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

input[type="search"], select {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px; font: inherit;
}
input[type="search"] { width: 220px; }
input:focus, select:focus, .btn:focus-visible, .card:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

.btn {
  display: inline-block;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 16px; font: inherit; cursor: pointer; text-decoration: none;
  transition: background .15s;
}
.btn:hover { background: #35373d; }
.btn.primary { background: var(--accent); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: #ff8a8c; }
.btn.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.link {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font: inherit; font-size: 13px; padding: 2px 6px;
}
.link:hover { color: var(--text); }

/* ---------- contenido ---------- */
main { padding: 24px; max-width: 1600px; margin: 0 auto; }

.dropzone {
  border: 2px dashed var(--line); border-radius: 16px;
  padding: 64px 24px; text-align: center;
  background: var(--panel);
}
.dropzone h2 { margin: 8px 0 4px; }
.dropzone p { margin: 0 0 20px; }
.dz-icon {
  width: 64px; height: 64px; margin: 0 auto; border-radius: 50%;
  display: grid; place-items: center; font-size: 28px;
  background: var(--panel-2); color: var(--accent-hover);
}

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

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; display: flex; flex-direction: column;
  transition: transform .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }

.thumb { position: relative; aspect-ratio: 16 / 9; background: #000; }
.thumb video, .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .hover-video { position: absolute; inset: 0; background: #000; }
.quality { display: inline-flex; align-items: center; gap: 6px; margin-right: 4px; }
.quality select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 14px;
}
.no-preview {
  position: absolute; inset: 0; display: grid; place-content: center; gap: 2px; text-align: center;
  background: repeating-linear-gradient(135deg, #202124 0 12px, #26272b 12px 24px); color: var(--muted);
}
.no-preview strong { font-size: 20px; color: var(--text); letter-spacing: .05em; }
.no-preview span { font-size: 12px; }
.thumb .play {
  position: absolute; inset: 0; display: grid; place-items: center;
  pointer-events: none; transition: opacity .15s;
}
.thumb .play span {
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(0, 0, 0, .6); display: grid; place-items: center; font-size: 17px; padding-left: 3px;
}
.card:hover .play { opacity: 0; }
.badge {
  position: absolute; right: 8px; bottom: 8px;
  background: rgba(0, 0, 0, .75); border-radius: 6px;
  padding: 2px 7px; font-size: 12px; font-variant-numeric: tabular-nums;
}
.card-info { padding: 10px 12px 12px; }
.card-title {
  margin: 0; font-weight: 600; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-meta { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

/* ---------- arrastrar y soltar ---------- */
.drag-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(88, 101, 242, .22); backdrop-filter: blur(3px);
  display: grid; place-items: center; pointer-events: none;
}
.drag-overlay div {
  border: 3px dashed var(--accent-hover); border-radius: 20px;
  padding: 48px 64px; font-size: 24px; font-weight: 700; background: rgba(26, 27, 30, .85);
}

/* ---------- panel de subidas ---------- */
.uploads {
  position: fixed; right: 20px; bottom: 20px; z-index: 30;
  width: min(380px, calc(100vw - 40px));
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
}
.uploads-head { display: flex; align-items: center; padding: 10px 12px 8px; gap: 4px; }
.bar { height: 4px; background: var(--panel-2); }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.uploads.collapsed ul { display: none; }
.uploads ul { list-style: none; margin: 0; padding: 4px 0; max-height: 320px; overflow-y: auto; }
.uploads li { padding: 8px 12px; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; }
.u-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; }
.u-status { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; grid-column: 1; }
.u-btns { grid-column: 2; grid-row: 1 / span 2; display: flex; align-items: center; gap: 2px; }
.u-x { font-size: 18px; line-height: 1; padding: 2px 6px; }
.u-x:hover { color: #ff8a8c; }
.u-bar { grid-column: 1 / -1; height: 4px; background: var(--panel-2); border-radius: 2px; overflow: hidden; }
.u-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
li.done .u-bar i { background: var(--ok); }
li.done .u-status { color: var(--ok); }
li.error .u-bar i { background: var(--danger); }
li.error .u-status { color: #ff8a8c; }
li.paused .u-bar i, li.orphan .u-bar i { background: #f0b232; }
li.orphan .u-status { color: #f0b232; }

/* ---------- reproductor ---------- */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .85); }
.modal-box {
  position: relative; width: min(1200px, 100%); max-height: 100%;
  background: var(--panel); border-radius: 16px; overflow: hidden;
  display: flex; flex-direction: column;
}
.player { background: #000; display: grid; place-items: center; min-height: 200px; }
.player video, .player img { max-width: 100%; max-height: 72vh; display: block; width: 100%; background: #000; }
.player video { height: auto; }
.player .fallback { padding: 48px 24px; text-align: center; color: var(--muted); }
.modal-info { display: flex; gap: 16px; justify-content: space-between; align-items: center; padding: 14px 18px; flex-wrap: wrap; }
.modal-text { min-width: 0; }
.modal-info h3 { margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.modal-info p { margin: 2px 0 0; font-size: 13px; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.close, .nav {
  position: absolute; z-index: 2; border: 0; cursor: pointer; color: #fff;
  background: rgba(0, 0, 0, .55); border-radius: 50%;
  width: 40px; height: 40px; font-size: 24px; line-height: 1;
}
.close:hover, .nav:hover { background: var(--accent); }
.close { top: 10px; right: 10px; }
.nav { top: 40%; transform: translateY(-50%); }
.nav.prev { left: 10px; }
.nav.next { right: 10px; }
/* No tapar los controles del video */
.nav { opacity: .0; transition: opacity .15s; }
.modal-box:hover .nav { opacity: 1; }

/* ---------- importar de Discord ---------- */
.dc-box { width: min(560px, 100%); overflow-y: auto; }
.dc-body { padding: 24px; }
.dc-body h3 { margin: 0 0 12px; font-size: 18px; padding-right: 36px; }
.dc-body p { margin: 0 0 12px; }
.dc-body ol { padding-left: 20px; margin: 0; }
.dc-body li { margin-bottom: 8px; }
.dc-body code {
  background: var(--panel-2); border-radius: 4px; padding: 1px 6px; font-size: 13px;
}
.small { font-size: 13px; }
.field { display: block; margin: 14px 0 6px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input {
  width: 100%; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font: inherit;
}
.dc-actions { display: flex; gap: 8px; margin-top: 14px; }
.dc-error {
  background: rgba(237, 66, 69, .15); border: 1px solid var(--danger);
  border-radius: 8px; padding: 10px 12px; margin-top: 12px !important;
}
.dc-headline { font-weight: 600; margin-top: 16px !important; }
.dc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 10px; margin: 14px 0; }
.dc-stats div { background: var(--panel-2); border-radius: 8px; padding: 8px 10px; }
.dc-stats dt { font-size: 12px; color: var(--muted); }
.dc-stats dd { margin: 0; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dc-errors { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: #ff8a8c; max-height: 120px; overflow-y: auto; }
.bar i.indeterminate { width: 35%; animation: slide 1.1s ease-in-out infinite; }
.bar i.full { width: 100%; animation: none; }
@keyframes slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
.bar { overflow: hidden; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(400px, 100%); text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 36px 28px;
}
.login-card h1 { margin: 16px 0 6px; font-size: 22px; }
.login-card p { margin: 0 0 20px; }
.brand-mark.big { width: 56px; height: 56px; font-size: 22px; margin: 0 auto; border-radius: 14px; }
.btn.discord { background: var(--accent); border-color: var(--accent); font-weight: 600; padding: 12px 20px; }
.btn.discord:hover { background: var(--accent-hover); }

.me { display: flex; align-items: center; gap: 8px; padding-left: 6px; }
.me img { width: 30px; height: 30px; border-radius: 50%; }
.me span { font-size: 14px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- filtros ---------- */
.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start; }
.filters { position: sticky; top: 90px; max-height: calc(100vh - 110px); overflow-y: auto; }
.filters h4 {
  margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.filters ul { list-style: none; margin: 0 0 22px; padding: 0; }
.facet {
  width: 100%; display: flex; justify-content: space-between; gap: 8px;
  background: none; border: 0; border-radius: 8px; color: var(--text);
  padding: 7px 10px; font: inherit; font-size: 14px; cursor: pointer; text-align: left;
}
.facet:hover { background: var(--panel); }
.facet[aria-pressed="true"] { background: var(--accent); }
.facet .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.facet[aria-pressed="true"] .n { color: #dfe2ff; }
.facet .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facet.empty .label { font-style: italic; color: var(--muted); }
.facet[aria-pressed="true"].empty .label { color: #fff; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar h2 { margin: 0; font-size: 18px; }
.inline { display: flex; align-items: center; gap: 6px; }
.btn.on { background: var(--accent); border-color: var(--accent); }

.group-title {
  grid-column: 1 / -1; margin: 10px 0 -4px; font-size: 16px;
  display: flex; align-items: baseline; gap: 8px;
}
.group-title:first-child { margin-top: 0; }
.group-title span { color: var(--muted); font-weight: 400; font-size: 13px; }

.tag {
  display: inline-block; background: rgba(88, 101, 242, .25); color: #c9cdfb;
  border-radius: 6px; padding: 1px 8px; font-size: 12px; font-weight: 600;
}
.tag.none { background: var(--panel-2); color: var(--muted); font-weight: 400; }
.thumb .tag { position: absolute; left: 8px; top: 8px; background: rgba(0, 0, 0, .7); color: #fff; }
.m-tags { margin: 4px 0 0 !important; }

/* selección múltiple */
.check {
  position: absolute; right: 8px; top: 8px; width: 24px; height: 24px; border-radius: 6px;
  border: 2px solid #fff; background: rgba(0, 0, 0, .45); display: none; place-items: center;
  font-size: 14px; color: #fff;
}
.selecting .check { display: grid; }
.selecting .card.locked { opacity: .45; cursor: not-allowed; }
.selecting .card.locked .check { display: none; }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.card.selected .check { background: var(--accent); border-color: var(--accent); }
.card.selected .check::after { content: "✓"; }
.selbar {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 35;
  width: min(640px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 12px;
  padding: 10px 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* personas que aparecen */
.modal-box { overflow-y: auto; }
.card-people {
  margin: 4px 0 0; font-size: 12.5px; color: #c9cdfb;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-people .sug { color: #f0b232; }
.m-caption {
  margin: 8px 0 0 !important; padding: 6px 10px; border-left: 3px solid var(--accent);
  background: var(--panel-2); border-radius: 0 6px 6px 0; font-size: 13.5px; white-space: pre-wrap;
}
.m-people { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.m-label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-right: 2px; }
.chips { display: contents; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 2px 4px 2px 10px; font-size: 13px;
}
.chip button {
  background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit;
  width: 20px; height: 20px; border-radius: 50%; line-height: 1;
}
.chip button:hover { background: var(--line); color: var(--text); }
.chip.suggested { border-style: dashed; border-color: #f0b232; }
.chip.suggested .ok:hover { background: var(--ok); color: #fff; }
.people-add { display: inline-flex; gap: 4px; }
.people-add input {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 13px; width: 160px;
}
.btn.small { padding: 4px 12px; font-size: 13px; border-radius: 999px; }

.modal.top { z-index: 45; }

.detect-list { list-style: none; margin: 8px 0; padding: 0; max-height: 38vh; overflow-y: auto; }
.detect-list li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.detect-list .n { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- roles ---------- */
.role-badge {
  font-size: 11px !important; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  border-radius: 6px; padding: 2px 6px; background: var(--panel-2); color: var(--muted);
}
.role-badge.admin { background: rgba(240, 178, 50, .18); color: #f0b232; }
.roles-search {
  width: 100%; margin: 4px 0 8px; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; font: inherit;
}
.roles-list { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow-y: auto; overflow-x: hidden; }
.roles-list select, .roles-list .fixed { flex-shrink: 0; }
.roles-list li { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.roles-list img { width: 28px; height: 28px; border-radius: 50%; background: var(--panel-2); }
.roles-list .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roles-list select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font: inherit; font-size: 13px;
}
.roles-list .fixed { font-size: 12.5px; color: #f0b232; }
.roles-box { width: min(620px, 100%); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted);
  padding: 8px 12px; font: inherit; cursor: pointer; margin-bottom: -1px;
}
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.role-cards { display: grid; gap: 10px; max-height: 52vh; overflow-y: auto; padding-right: 2px; }
.role-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--panel-2); }
.role-card header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.role-card header input {
  flex: 1; min-width: 0; background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 5px 8px; font: inherit; font-weight: 600;
}
.role-card header strong { flex: 1; }
.role-card .count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 2px 12px; }
.perm-grid label { font-size: 13px; display: flex; gap: 6px; align-items: center; cursor: pointer; }
.perm-grid input:disabled + span { color: var(--muted); }
.new-role { display: flex; gap: 8px; margin-top: 12px; }
.new-role input {
  flex: 1; min-width: 0; background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 12px; font: inherit;
}

/* ---------- recortar ---------- */
.modal.top2 { z-index: 47; }
.trim-box { width: min(900px, 100%); }
.trim-player { background: #000; display: grid; place-items: center; }
.trim-player video { width: 100%; max-height: 46vh; display: block; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.trim-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.trim-track {
  position: relative; height: 44px; border-radius: 8px; background: var(--panel-2);
  border: 1px solid var(--line); cursor: pointer; touch-action: none; user-select: none;
}
.trim-range {
  position: absolute; top: 0; bottom: 0; background: rgba(88, 101, 242, .35);
  border-top: 2px solid var(--accent); border-bottom: 2px solid var(--accent);
}
.trim-head { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: #fff; pointer-events: none; }
.trim-handle {
  position: absolute; top: -2px; bottom: -2px; width: 14px; margin-left: -7px;
  background: var(--accent); border-radius: 4px; cursor: ew-resize;
}
.trim-handle::after {
  content: ""; position: absolute; left: 5px; right: 5px; top: 30%; bottom: 30%;
  border-left: 1px solid rgba(255, 255, 255, .7); border-right: 1px solid rgba(255, 255, 255, .7);
}
.trim-handle:focus-visible { outline: 2px solid #fff; }
.trim-fields { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 12px 0 6px; }
.time-input {
  width: 92px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 5px 8px;
}
.time-input.bad { border-color: var(--danger); }
.opts { border: 1px solid var(--line); border-radius: 8px; margin: 10px 0 0; padding: 8px 12px 10px; }
.opts legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
.opts label { display: block; font-size: 13.5px; margin-top: 4px; cursor: pointer; }
.small-box { width: min(440px, 100%); }
.up-names { margin: 0 0 4px; padding-left: 18px; font-size: 13px; color: var(--muted); }
.up-names li { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .filters { position: static; max-height: none; display: flex; flex-direction: column; gap: 4px; }
  .filters h4 { margin: 0; }
  .filters ul { display: flex; gap: 6px; overflow-x: auto; margin: 0 0 8px; padding-bottom: 4px; }
  .facet { width: auto; white-space: nowrap; background: var(--panel); }
  .me span { display: none; }
}

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 60;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 18px; box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
}

@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  main { padding: 16px; }
  input[type="search"] { width: 100%; flex: 1; }
  .tools { width: 100%; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
}
