:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --border: #e5e5e8;
  --text: #16161a;
  --text-muted: #6b6b74;
  --accent: #16161a;
  --accent-contrast: #ffffff;
  --danger: #c0392b;
  --success: #1e8e5a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

/* ---------- Entrance animations ---------- */
/* Everything that loads eases in. Respects prefers-reduced-motion — no animation
   property is applied at all in that case, so elements just render at their normal
   (visible) state instantly instead of being stuck invisible. */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@media (prefers-reduced-motion: no-preference) {
  .auth-card,
  .sidebar,
  .main > *,
  .video-card {
    animation: fadeInUp 0.45s ease-out both;
  }

  .sidebar-nav a,
  .sidebar-brand {
    animation: fadeInUp 0.4s ease-out both;
  }

  /* Cascade: header, lead, banner/filter-bar, grid — each direct child of .main
     a beat behind the last, so the page reads top-to-bottom instead of flashing in at once. */
  .main > *:nth-child(1) { animation-delay: 0ms; }
  .main > *:nth-child(2) { animation-delay: 60ms; }
  .main > *:nth-child(3) { animation-delay: 120ms; }
  .main > *:nth-child(4) { animation-delay: 180ms; }
  .main > *:nth-child(5) { animation-delay: 240ms; }
  .main > *:nth-child(6) { animation-delay: 300ms; }

  .sidebar-nav a { animation-delay: calc(var(--i, 0) * 60ms); }

  /* Video cards stagger by their render order (--i is set inline per card). */
  .video-card { animation-delay: calc(var(--i, 0) * 40ms); }

  .modal-backdrop { animation: fadeIn 0.2s ease-out both; }
  .modal { animation: scaleIn 0.25s ease-out both; }
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

a { color: inherit; }

/* ---------- Auth pages ---------- */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 36px;
}

.auth-card h1 {
  font-size: 22px;
  margin: 0 0 4px;
}

.auth-card p.sub {
  color: var(--text-muted);
  margin: 0 0 28px;
  font-size: 14px;
}

.field { margin-bottom: 18px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}

.field input:focus {
  outline: none;
  border-color: var(--text);
}

.plan-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 22px;
}

.plan-option {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  position: relative;
}

.plan-option input { position: absolute; top: 12px; right: 12px; }

.plan-option .plan-name { font-weight: 600; font-size: 14px; }
.plan-option .plan-price { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.plan-option:has(input:checked) {
  border-color: var(--text);
  background: #fafafa;
}

.btn-primary {
  width: 100%;
  padding: 11px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover { opacity: 0.9; }

.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-switch a { font-weight: 600; text-decoration: none; }

.errors {
  background: #fdecea;
  border: 1px solid #f5c6c2;
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 18px;
}

/* ---------- Dashboard layout ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  font-weight: 700;
  font-size: 15px;
  padding: 0 8px 24px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.sidebar-nav a {
  padding: 9px 10px;
  border-radius: 7px;
  text-decoration: none;
  font-size: 14px;
  color: var(--text-muted);
}

.sidebar-nav a:hover { background: var(--bg); color: var(--text); }
.sidebar-nav a.active { background: var(--text); color: var(--accent-contrast); }

.sidebar-logout { margin-top: auto; }
.sidebar-logout button {
  width: 100%;
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}
.sidebar-logout button:hover { color: var(--text); }

.main {
  flex: 1;
  padding: 36px 40px;
  max-width: 1100px;
}

.main h1 { font-size: 24px; margin: 0 0 6px; }
.main p.lead { color: var(--text-muted); margin: 0 0 28px; }

.banner {
  border-radius: 8px;
  padding: 14px 18px;
  font-size: 14px;
  margin-bottom: 24px;
}

.banner-warning { background: #fff8e6; border: 1px solid #f0dca0; color: #7a5c00; }
.banner-success { background: #eaf7ef; border: 1px solid #b9e4c9; color: var(--success); }

/* ---------- Video library ---------- */

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}

.filter-pill {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.filter-pill:hover { color: var(--text); }

.filter-pill.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--accent-contrast);
}

.tag-pill {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.tag-pill:hover { color: var(--text); }

.tag-pill.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--accent-contrast);
}

.no-results {
  color: var(--text-muted);
  font-size: 14px;
}

.video-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  display: block;
}

/* Author's own display:block above would otherwise win over the UA [hidden] rule — make the
   filter's hidden attribute actually hide cards. */
.video-card[hidden] { display: none; }

.video-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: #eee;
}

.video-card .video-info { padding: 12px 14px; }
.video-card .video-title { font-size: 14px; font-weight: 600; margin: 0 0 4px; }
.video-card .video-duration { font-size: 12px; color: var(--text-muted); }

.video-player-wrap {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}

.video-player-wrap iframe {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%; border: 0;
}

/* ---------- Video lightbox modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 12, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  z-index: 2;
}

.modal-close:hover { background: rgba(0, 0, 0, 0.12); }

.modal-video-wrap {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
  background: #000;
}

.modal-video-wrap iframe {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%; border: 0;
}

.modal-body { padding: 22px 24px; }

.modal-title { font-size: 19px; font-weight: 700; margin: 0 0 8px; }

.modal-description {
  color: var(--text-muted);
  font-size: 14px;
  white-space: pre-line;
  margin: 0;
}
