:root {
  color-scheme: dark;
  --bg: #07130f;
  --card: #0f1f18;
  --card-2: #143126;
  --text: #f8fafc;
  --muted: #9fb2a9;
  --accent: #10b981;
  --accent-2: #059669;
  --danger: #ef4444;
  --border: rgba(255,255,255,.10);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 0%, rgba(16,185,129,.18), transparent 38%),
    radial-gradient(circle at 85% 10%, rgba(5,150,105,.12), transparent 35%),
    var(--bg);
  color: var(--text);
}
button, input, textarea { font: inherit; }
button, .button {
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  cursor: pointer;
  text-decoration: none;
  font-weight: 700;
}
.secondary { background: var(--card-2); border: 1px solid var(--border); }
.ghost { background: transparent; border: 1px solid var(--border); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 18px max(20px, calc((100vw - 1120px)/2));
  background: rgba(7,19,15,.84);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 22px; }
.top-actions { display: flex; gap: 10px; }

.container { width: min(1120px, calc(100% - 28px)); margin: 28px auto 60px; }
.success, .alert {
  border-radius: 12px; padding: 12px 14px; margin: 16px 0;
}
.success { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.35); }
.alert { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.35); }

.series-block { margin-bottom: 36px; }
.series-block h2 { margin: 0 0 10px; font-size: 28px; }
.series-block h3 { color: #d1fae5; margin: 18px 0 12px; }

.episode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}
.episode-card {
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(15,31,24,.92);
  border-radius: 18px;
  transition: .2s ease;
}
.episode-card:hover {
  transform: translateY(-2px);
  border-color: rgba(16,185,129,.55);
}
.poster {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  background:
    linear-gradient(135deg, rgba(16,185,129,.25), rgba(5,150,105,.08)),
    #081711;
  color: white;
  text-decoration: none;
  font-size: 42px;
}
.poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.episode-body { padding: 14px; }
.episode-title {
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  line-height: 1.35;
}
.episode-title:hover { color: #86efac; }
.desc {
  color: #cbd5d1;
  font-size: 14px;
  line-height: 1.55;
  max-height: 68px;
  overflow: hidden;
}
.danger-button {
  width: 100%;
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.35);
  color: #fecaca;
  margin-top: 8px;
}

.empty { text-align: center; padding: 70px 20px; }
.empty-icon { font-size: 64px; opacity: .8; }

.login-page { display: grid; place-items: center; padding: 20px; }
.login-card {
  width: min(420px, 100%);
  padding: 32px;
  background: rgba(15,31,24,.94);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 24px 80px rgba(0,0,0,.35);
}
.login-card h1 { margin: 8px 0 4px; }
.logo { font-size: 46px; }

label { display: block; margin: 16px 0 8px; color: #cbd5e1; }
input, textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: white;
  background: #081711;
  outline: none;
}
textarea { resize: vertical; }
input:focus, textarea:focus { border-color: var(--accent); }
.login-card button, .upload-form > button { width: 100%; margin-top: 18px; }

dialog {
  width: min(560px, calc(100% - 24px));
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  background: var(--card);
  padding: 0;
}
dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(6px); }
.upload-form { padding: 22px; max-height: 90vh; overflow: auto; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.dialog-head h2 { margin: 0; }
.icon-button {
  width: 38px; height: 38px; padding: 0; border-radius: 10px;
  background: transparent; border: 1px solid var(--border);
}
.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.watch-page { background: #000; }
.watch-header {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  align-items: center;
  padding: 18px max(14px, calc((100vw - 1180px)/2));
  background: #050505;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.watch-header h1 { margin: 0 0 4px; font-size: 20px; }
.watch-container {
  width: min(1180px, calc(100% - 24px));
  margin: 18px auto 60px;
}
video {
  display: block;
  width: 100%;
  max-height: 78vh;
  background: #000;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.08);
}
.watch-description {
  margin-top: 20px;
  padding: 20px;
  background: rgba(15,31,24,.92);
  border: 1px solid var(--border);
  border-radius: 16px;
}
.watch-description h2 { margin-top: 0; }

@media (max-width: 680px) {
  .topbar { align-items: flex-start; padding: 14px; }
  .top-actions { gap: 6px; }
  .top-actions button, .top-actions .button { padding: 10px 12px; }
  .episode-grid { grid-template-columns: 1fr; }
  .watch-header { grid-template-columns: 1fr; }
}
