:root {
  --bg: #0b0d14;
  --bg2: #11141e;
  --card: rgba(22, 26, 38, .78);
  --line: rgba(255, 255, 255, .08);
  --line2: rgba(255, 255, 255, .16);
  --fg: #e8eaf2;
  --muted: #8b90a3;
  --acc: #8b5cf6;
  --acc2: #06b6d4;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --field: rgba(255, 255, 255, .04);
  --shadow: 0 20px 60px rgba(0, 0, 0, .45);
  --r: 16px;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6fb;
    --bg2: #eceef6;
    --card: rgba(255, 255, 255, .85);
    --line: rgba(15, 20, 40, .08);
    --line2: rgba(15, 20, 40, .16);
    --fg: #151826;
    --muted: #646a80;
    --field: rgba(15, 20, 40, .03);
    --shadow: 0 20px 50px rgba(30, 35, 70, .12);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(139, 92, 246, .22), transparent 60%),
    radial-gradient(800px 500px at 110% 10%, rgba(6, 182, 212, .16), transparent 60%),
    radial-gradient(700px 400px at 50% 120%, rgba(139, 92, 246, .10), transparent 60%);
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
p { margin: 0; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- bloques ---------- */
.center { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { font-size: 26px; font-weight: 750; }
.brand p { color: var(--muted); font-size: 14px; }
.brand.small { gap: 10px; font-size: 18px; }
.brand img { display: block; border-radius: 10px; }

/* ---------- botones ---------- */
.btn {
  appearance: none; border: 1px solid var(--line2); background: var(--field); color: var(--fg);
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 10px 18px; border-radius: 10px; cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease, opacity .15s;
}
.btn:hover { border-color: var(--acc); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.primary {
  border-color: transparent; color: #fff;
  background: linear-gradient(135deg, var(--acc), #6d28d9);
  box-shadow: 0 6px 20px rgba(139, 92, 246, .35);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--fg); border-color: var(--line2); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.wide { width: 100%; padding: 12px; font-size: 15px; }
:focus-visible { outline: 2px solid var(--acc2); outline-offset: 2px; }

/* ---------- login ---------- */
.login { width: 100%; max-width: 390px; padding: 34px 30px 26px; display: grid; gap: 18px; }
.login .brand { margin-bottom: 6px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input {
  width: 100%; font: inherit; color: var(--fg);
  background: var(--field); border: 1px solid var(--line2); border-radius: 10px;
  padding: 11px 13px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--acc); box-shadow: 0 0 0 4px rgba(139, 92, 246, .18); }
.pw { position: relative; }
.pw input { padding-right: 44px; }
.eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px;
}
.eye svg, .drop-ico svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.eye:hover, .eye.on { color: var(--fg); }
.err {
  background: rgba(239, 68, 68, .1); border: 1px solid rgba(239, 68, 68, .35); color: #fca5a5;
  padding: 9px 12px; border-radius: 10px; font-size: 13.5px;
}
@media (prefers-color-scheme: light) { .err { color: #b91c1c; } }
.fine { color: var(--muted); font-size: 12.5px; text-align: center; }
.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* ---------- cabecera ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px max(16px, calc((100vw - 868px) / 2));
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.who { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; min-width: 0; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--acc), var(--acc2)); color: #fff; font-size: 13px; text-transform: uppercase;
}
.quota { color: var(--muted); font-weight: 500; font-size: 12.5px; padding-right: 6px; }

/* ---------- contenido ---------- */
.wrap { max-width: 900px; margin: 0 auto; padding: 36px 16px 60px; display: grid; gap: 22px; }
.intro h2 { font-size: 28px; font-weight: 750; }
.intro p { color: var(--muted); margin-top: 6px; }

.drop {
  border: 2px dashed var(--line2); border-radius: 20px;
  background: var(--card);
  padding: 44px 20px; text-align: center; cursor: pointer;
  display: grid; justify-items: center; gap: 8px;
  transition: border-color .15s, background .15s, transform .15s;
}
.drop:hover { border-color: rgba(139, 92, 246, .6); }
.drop.over {
  border-color: var(--acc); border-style: solid; transform: scale(1.01);
  background: color-mix(in srgb, var(--acc) 10%, var(--card));
}
.drop-ico {
  width: 66px; height: 66px; border-radius: 18px; display: grid; place-items: center; margin-bottom: 6px;
  color: #fff; background: linear-gradient(135deg, var(--acc), var(--acc2));
  box-shadow: 0 10px 30px rgba(139, 92, 246, .35);
}
.drop.over .drop-ico { animation: bob .8s ease-in-out infinite alternate; }
@keyframes bob { to { transform: translateY(-5px); } }
.drop-t { font-size: 18px; font-weight: 650; }
.drop-s { color: var(--muted); font-size: 13px; }
.drop-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.drop-f { color: var(--muted); font-size: 12.5px; margin-top: 10px; }

/* ---------- cola ---------- */
.queue { padding: 20px 20px 8px; }
.q-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.q-head h3 { font-size: 17px; }
.q-total { height: 4px; border-radius: 4px; background: var(--line); margin: 14px 0 6px; overflow: hidden; }
#q-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--acc), var(--acc2)); transition: width .4s ease; }
#q-list { list-style: none; margin: 0; padding: 0; }
.item { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.ficon {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  font-size: 10.5px; font-weight: 750; letter-spacing: .03em; text-transform: uppercase;
  background: rgba(139, 92, 246, .14); color: #c4b5fd;
}
@media (prefers-color-scheme: light) { .ficon { color: #6d28d9; } }
.item.done .ficon { background: rgba(34, 197, 94, .14); color: var(--ok); }
.item.error .ficon { background: rgba(239, 68, 68, .14); color: var(--bad); }
.meta { min-width: 0; }
.fname { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fdir { color: var(--muted); font-weight: 500; }
.fsub { color: var(--muted); font-size: 12.5px; margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.fsub .st { font-weight: 600; }
.item.done .st { color: var(--ok); }
.item.error .st { color: var(--bad); }
.item.hashing .st, .item.wait .st { color: var(--warn); }
.bar { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; width: 0; border-radius: 6px; background: linear-gradient(90deg, var(--acc), var(--acc2)); transition: width .3s ease; }
.item.hashing .bar > i { background: repeating-linear-gradient(45deg, var(--warn) 0 8px, color-mix(in srgb, var(--warn) 70%, transparent) 8px 16px); }
.item.done .bar > i { background: var(--ok); }
.item.error .bar > i { background: var(--bad); }
.pct { font-variant-numeric: tabular-nums; font-weight: 650; font-size: 14px; min-width: 48px; text-align: right; }
.x {
  border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1;
  padding: 4px 6px; border-radius: 6px; margin-left: 4px;
}
.x:hover { color: var(--fg); background: var(--field); }
.right { display: flex; align-items: center; }

/* ---------- ayuda ---------- */
.tips details { border: 1px solid var(--line); border-radius: var(--r); background: var(--card); }
.tips summary { cursor: pointer; padding: 16px 20px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
.tips summary::after { content: "+"; color: var(--muted); font-size: 18px; line-height: 1; }
.tips details[open] summary::after { content: "−"; }
.tips summary::-webkit-details-marker { display: none; }
.tips-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; padding: 0 20px 20px; }
.tips h4 { font-size: 14px; margin-bottom: 4px; }
.tips p { color: var(--muted); font-size: 13.5px; margin-bottom: 6px; }
.tips code {
  display: block; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px;
  background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; margin-top: 5px;
  overflow-wrap: anywhere;
}

/* ---------- varios ---------- */
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line2); border-top-color: var(--acc); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  background: var(--fg); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}

@media (max-width: 560px) {
  .intro h2 { font-size: 23px; }
  .drop { padding: 32px 16px; }
  .quota, #u-name { display: none; }
  .item { grid-template-columns: 34px 1fr auto; gap: 10px; }
  .ficon { width: 34px; height: 34px; font-size: 9.5px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- pestañas ---------- */
.tabs {
  display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; justify-self: start;
  background: var(--card); border: 1px solid var(--line);
}
.tabs button {
  appearance: none; border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; font-size: 14px;
  padding: 8px 16px; border-radius: 9px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
}
.tabs button:hover { color: var(--fg); }
.tabs button.on { background: var(--field); color: var(--fg); box-shadow: inset 0 0 0 1px var(--line2); }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: 12px; line-height: 20px; text-align: center;
  background: linear-gradient(135deg, var(--acc), var(--acc2)); color: #fff;
}
.tab { display: grid; gap: 22px; }

/* ---------- torrents ---------- */
.tor-add { padding: 22px 20px; display: grid; gap: 14px; transition: border-color .15s, background .15s; }
.tor-add.over { border-color: var(--acc); background: color-mix(in srgb, var(--acc) 10%, var(--card)); }
.tor-row { display: flex; gap: 10px; }
.tor-row input { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13.5px; }
.tor-alt { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tor-note { font-size: 12.5px; }
.tor-list { list-style: none; margin: 0; padding: 0; }
.empty { padding: 6px 0 14px; }
.item.wait .ficon, .item.upload .ficon { font-size: 15px; }
@media (max-width: 560px) {
  .tor-row { flex-direction: column; }
  .tabs { justify-self: stretch; }
  .tabs button { flex: 1; justify-content: center; padding: 8px 10px; }
}
