:root {
  --bg: #0e1116;
  --surface: #171c24;
  --surface-2: #1f2630;
  --border: #2a323d;
  --text: #e6e9ef;
  --muted: #8b95a5;
  --primary: #4f8cff;
  --primary-hover: #3d7bf0;
  --success: #34c759;
  --danger: #ff5c5c;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger); font-size: 0.875rem; min-height: 1.2em; margin: 0.25rem 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

/* Buttons */
.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 0.55rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: transparent; }
.btn.small { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 380px; }
.logo { margin: 0 0 0.25rem; font-size: 1.5rem; }
.logo.small { font-size: 1.1rem; font-weight: 600; }
.tabs { display: flex; gap: 0.5rem; margin: 1.25rem 0 1rem; }
.tab {
  flex: 1; background: transparent; border: none; color: var(--muted);
  padding: 0.5rem; cursor: pointer; border-bottom: 2px solid transparent; font-size: 0.95rem;
}
.tab.active { color: var(--text); border-bottom-color: var(--primary); }
form label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.85rem; }
form input {
  width: 100%; margin-top: 0.3rem; padding: 0.6rem 0.75rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 0.95rem;
}
form input:focus { outline: none; border-color: var(--primary); }
#auth-submit { width: 100%; margin-top: 0.5rem; }

/* Topbar */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.85rem 1.5rem; border-bottom: 1px solid var(--border); background: var(--surface);
}
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.quota { font-variant-numeric: tabular-nums; }

.container { max-width: 820px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 0.75rem; }

/* Add card */
.add-card h2 { margin-top: 0; }
.add-row { display: flex; gap: 0.5rem; }
.add-row input {
  flex: 1; padding: 0.6rem 0.75rem; background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; color: var(--text);
}
.add-row input:focus { outline: none; border-color: var(--primary); }
.or { text-align: center; color: var(--muted); margin: 0.75rem 0; font-size: 0.85rem; }
.file-drop {
  display: block; text-align: center; padding: 1.25rem; border: 1.5px dashed var(--border);
  border-radius: 8px; color: var(--muted); cursor: pointer;
}
.file-drop:hover { border-color: var(--primary); color: var(--text); }

/* Torrent list */
.list { display: flex; flex-direction: column; gap: 0.75rem; }
.torrent {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.25rem;
}
.torrent-head { display: flex; justify-content: space-between; gap: 1rem; align-items: start; }
.torrent-name { font-weight: 600; word-break: break-word; }
.badge { font-size: 0.7rem; padding: 0.15rem 0.5rem; border-radius: 999px; white-space: nowrap; }
.badge.downloading { background: rgba(79,140,255,0.15); color: var(--primary); }
.badge.completed { background: rgba(52,199,89,0.15); color: var(--success); }
.badge.error { background: rgba(255,92,92,0.15); color: var(--danger); }

.progress { height: 6px; background: var(--surface-2); border-radius: 999px; margin: 0.75rem 0 0.4rem; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); width: 0%; transition: width 0.4s; }
.torrent.completed .progress-bar { background: var(--success); }
.stats { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.files { margin-top: 0.85rem; border-top: 1px solid var(--border); padding-top: 0.5rem; }
.file-row { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.4rem 0; font-size: 0.875rem; }
.file-row .fname { word-break: break-word; }
.file-actions { display: flex; gap: 0.4rem; white-space: nowrap; }
.torrent-actions { margin-top: 0.75rem; display: flex; justify-content: flex-end; }
a.plain { color: inherit; text-decoration: none; }

.banner {
  background: rgba(255, 92, 92, 0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.zip-bar {
  display: flex;
  gap: 0.4rem;
  padding-bottom: 0.5rem;
  margin-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}
