:root {
  --bg: #0f1115;
  --surface: #1a1d24;
  --border: #2a2f3a;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --ok: #22c55e;
  --radius: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 0;
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
}
.site-header nav a {
  margin-left: 1.25rem;
  color: var(--muted);
  font-size: 0.95rem;
}
.site-header nav a:hover {
  color: var(--text);
}

main {
  flex: 1;
  padding: 2rem 0 3rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  color: var(--muted);
  font-size: 0.875rem;
  text-align: center;
}

/* Hero / search */
.hero {
  text-align: center;
  margin-bottom: 2.5rem;
}
.hero h1 {
  font-size: 1.85rem;
  margin-bottom: 0.4rem;
}
.hero p {
  color: var(--muted);
  margin-bottom: 1.25rem;
}
.search-form {
  display: flex;
  max-width: 480px;
  margin: 0 auto;
  gap: 0.5rem;
}
.search-form input {
  flex: 1;
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}
.search-form button {
  padding: 0.65rem 1.2rem;
  border-radius: var(--radius);
  border: none;
  background: var(--primary);
  color: white;
  font-weight: 600;
  cursor: pointer;
}
.search-form button:hover {
  background: var(--primary-hover);
}

/* Video grid */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.5rem;
}
.video-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: transform 0.15s, border-color 0.15s;
  color: inherit;
  text-decoration: none;
  display: block;
}
.video-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  text-decoration: none;
}
.thumb-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
}
.thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--muted);
  background: #111;
}
.duration {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0,0,0,0.8);
  color: white;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  z-index: 2;
}
.card-body {
  padding: 0.85rem 1rem 1.1rem;
}
.card-body h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.meta, .small {
  font-size: 0.8rem;
  color: var(--muted);
}
.results-meta {
  color: var(--muted);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

/* Animated hover thumbnails */
.thumb-wrap video.hover-clip {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
  position: absolute;
  top: 0;
  left: 0;
}

/* Watch page */
.player-wrap {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.player-wrap video {
  width: 100%;
  max-height: 70vh;
  display: block;
  background: #000;
}
.video-header h1 {
  font-size: 1.4rem;
  margin-bottom: 0.4rem;
}
.tags {
  margin-top: 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.tag {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--muted);
}
.description {
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  white-space: pre-wrap;
}
.related {
  margin-top: 2.5rem;
}
.related h2 {
  font-size: 1.15rem;
  margin-bottom: 1rem;
}
.related-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

/* Admin */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.admin-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
}
.stat-label {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.admin-table th,
.admin-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.admin-table th {
  background: #151820;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.admin-table tr:last-child td {
  border-bottom: none;
}
.actions {
  white-space: nowrap;
}
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: #333;
  color: var(--muted);
}
.badge.ok {
  background: rgba(34, 197, 94, 0.15);
  color: var(--ok);
}

/* Forms */
.form {
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 500;
}
.form input[type="text"],
.form input[type="password"],
.form input[type="number"],
.form input[type="file"],
.form textarea {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}
.form textarea {
  resize: vertical;
}
.checkbox {
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem !important;
}
.auth-card {
  max-width: 380px;
  margin: 3rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}
.auth-card h1 {
  margin-bottom: 1.25rem;
  font-size: 1.35rem;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover {
  background: #22262f;
  text-decoration: none;
}
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-hover);
}
.btn-danger {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.4);
}
.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
}
.btn-ghost {
  background: transparent;
}

.error {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.empty, .empty-state {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
}
.empty-state h1 {
  color: var(--text);
  margin-bottom: 0.5rem;
}
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  margin-top: 2.5rem;
  color: var(--muted);
}
.muted {
  color: var(--muted);
}

@media (max-width: 600px) {
  .admin-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .admin-table {
    font-size: 0.85rem;
  }
}