:root {
  --bg: #0f1115;
  --card: #171a21;
  --border: #262b36;
  --text: #f2f3f5;
  --muted: #8b909c;
  --accent: #6366f1;
  --accent-hover: #7577f3;
  --error: #ef4444;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding: 24px;
}

.wrap { width: 100%; max-width: 480px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 32px;
}

.hidden { display: none !important; }
.center { text-align: center; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.06);
}

.upload-icon { color: var(--muted); margin-bottom: 12px; }
.dropzone.dragover .upload-icon { color: var(--accent); }

.drop-title { font-size: 17px; font-weight: 600; margin: 0 0 6px; }
.muted { color: var(--muted); font-size: 14px; margin: 0; }
.error-title { color: var(--error); }

.spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto 16px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.progress-label {
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 14px;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.15s ease;
}

.check {
  width: 48px;
  height: 48px;
  line-height: 48px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  font-size: 24px;
}

.link-row {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

.link-input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f1115;
  color: var(--text);
  font-size: 13px;
}

.btn {
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn:hover { background: var(--accent-hover); }

.link-reset {
  margin-top: 16px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
}

/* Watch page */
video {
  width: 100%;
  border-radius: 10px;
  display: block;
  background: black;
}

.small { font-size: 12px; margin-top: 12px; }

/* Admin page */
.admin-body {
  align-items: flex-start;
  padding: 32px 16px;
}

.admin-wrap { width: 100%; max-width: 1100px; margin: 0 auto; }

.admin-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.admin-title { margin: 0; font-size: 22px; }

.refresh-link { color: var(--muted); font-size: 13px; text-decoration: none; }
.refresh-link:hover { color: var(--text); }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-success { background: rgba(34, 197, 94, 0.12); color: #22c55e; border: 1px solid rgba(34, 197, 94, 0.3); }
.alert-error { background: rgba(239, 68, 68, 0.12); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }
.alert-info { background: rgba(99, 102, 241, 0.12); color: #a5a8f7; border: 1px solid rgba(99, 102, 241, 0.3); }

.toolbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.copy-btn {
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}
.copy-btn:hover { color: var(--text); border-color: var(--accent); }

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.stat-num { font-size: 22px; font-weight: 700; margin-bottom: 2px; }

.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.tabs { display: flex; gap: 6px; }

.tab {
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--border);
}

.tab-active { color: var(--text); background: rgba(99, 102, 241, 0.12); border-color: var(--accent); }

.search-form { display: flex; gap: 8px; }
.search-form .link-input { width: 220px; }

.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }

tr:last-child td { border-bottom: none; }

.truncate {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mono-cell {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 12px;
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-green { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.badge-red { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.badge-gray { background: rgba(139, 144, 156, 0.15); color: var(--muted); }

.btn-danger {
  padding: 6px 12px;
  border-radius: 7px;
  border: 1px solid rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger:hover { background: rgba(239, 68, 68, 0.2); }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 18px;
}

.btn-disabled { opacity: 0.4; pointer-events: none; }

@media (max-width: 640px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .search-form .link-input { width: 140px; }
}
