* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: #141414;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ---------- Top nav ---------- */
.cv-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: linear-gradient(to bottom, rgba(20,20,20,0.9), transparent);
  transition: background .2s ease;
}
.cv-nav.cv-nav-solid { background: #141414; box-shadow: 0 2px 10px rgba(0,0,0,0.4); }

.cv-brand {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #e50914;
  flex-shrink: 0;
}

.cv-search-form {
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 4px;
  padding: 6px 10px;
}
.cv-search-form input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 14px;
  padding: 4px 6px;
}
.cv-search-form input::placeholder { color: #aaa; }
.cv-search-form button {
  background: transparent;
  border: none;
  color: #ccc;
  cursor: pointer;
  padding: 2px 4px;
  display: flex;
  align-items: center;
}

/* ---------- Hero ---------- */
.cv-hero {
  position: relative;
  width: 100%;
  height: 62vw;
  max-height: 640px;
  min-height: 320px;
  color: #fff;
  overflow: hidden;
  background: #1c1c1c;
}
.cv-hero-bg {
  position: absolute; inset: 0;
  background-size: cover;
  background-position: center 20%;
}
.cv-hero-bg.cv-placeholder-bg {
  background: linear-gradient(135deg, #2b2b2b, #141414);
}
.cv-hero::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to top, #141414 2%, rgba(20,20,20,0.15) 55%, rgba(20,20,20,0.55) 100%),
              linear-gradient(to right, rgba(20,20,20,0.75) 0%, rgba(20,20,20,0.15) 55%);
}
.cv-hero-content {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 48px;
  z-index: 2;
  max-width: 620px;
}
.cv-hero-title {
  font-size: clamp(24px, 5vw, 44px);
  font-weight: 800;
  margin: 0 0 10px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
}
.cv-hero-overview {
  font-size: 14px;
  line-height: 1.5;
  color: #e5e5e5;
  margin: 0 0 18px;
  max-width: 520px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cv-hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.cv-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: 4px;
  font-size: 15px;
  font-weight: 700;
  border: none;
  cursor: pointer;
}
.cv-btn-primary { background: #fff; color: #141414; }
.cv-btn-primary:active { background: #d4d4d4; }
.cv-btn-secondary { background: rgba(109,109,110,0.6); color: #fff; }
.cv-btn-secondary:active { background: rgba(109,109,110,0.4); }

/* ---------- Rows ---------- */
.cv-rows { padding: 8px 0 60px; margin-top: -60px; position: relative; z-index: 3; }
.cv-row { margin-bottom: 28px; }
.cv-row-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 10px;
  padding: 0 24px;
}
.cv-row-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 24px 12px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.cv-row-scroll::-webkit-scrollbar { height: 6px; }
.cv-row-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

.cv-card {
  flex: 0 0 auto;
  width: 130px;
  scroll-snap-align: start;
  border-radius: 4px;
  overflow: hidden;
  background: #222;
  transition: transform .15s ease;
}
.cv-card:active { transform: scale(0.96); }
.cv-card-poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  background: #2b2b2b;
  display: block;
}
.cv-card-poster-placeholder {
  width: 100%;
  aspect-ratio: 2 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2b2b2b, #1a1a1a);
  color: #666;
  text-align: center;
  font-size: 12px;
  padding: 8px;
}
.cv-card-label {
  font-size: 12px;
  padding: 6px 6px 8px;
  color: #ddd;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Grid (search results) ---------- */
.cv-page-pad { padding: 90px 24px 60px; max-width: 1400px; margin: 0 auto; }
.cv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 14px;
}
.cv-empty-state {
  text-align: center;
  color: #999;
  padding: 60px 20px;
}

/* ---------- Setup notice (no TMDB key configured) ---------- */
.cv-setup-notice {
  max-width: 560px;
  margin: 120px auto 0;
  padding: 28px 24px;
  background: #1f1f1f;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  text-align: center;
}
.cv-setup-notice h2 { margin-top: 0; }
.cv-setup-notice code {
  display: block;
  background: #111;
  padding: 10px 14px;
  border-radius: 6px;
  margin: 14px 0;
  font-size: 13px;
  word-break: break-all;
}
.cv-setup-notice a { color: #e50914; font-weight: 600; }

/* ---------- Watch page ---------- */
.cv-watch-hero {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 80vh;
  background: #000;
  overflow: hidden;
}
.cv-watch-bg {
  position: absolute; inset: 0;
  background-size: cover;
  background-position: center;
  filter: brightness(0.55);
}
.cv-watch-bg.cv-placeholder-bg {
  background: linear-gradient(135deg, #2b2b2b, #101010);
  filter: none;
}
.cv-watch-play-overlay {
  position: absolute; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 4;
}
.cv-watch-play-btn {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: rgba(255,255,255,0.92);
  color: #141414;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  transition: transform .15s ease;
}
.cv-watch-play-overlay:active .cv-watch-play-btn { transform: scale(0.94); }

.cv-watch-iframe-wrap {
  position: absolute; inset: 0;
  z-index: 5;
  background: #000;
}
.cv-watch-iframe-wrap iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.cv-watch-info { padding: 20px 24px 40px; max-width: 900px; margin: 0 auto; }
.cv-watch-title { font-size: clamp(22px, 4vw, 32px); font-weight: 800; margin: 0 0 8px; }
.cv-watch-meta { color: #999; font-size: 13px; margin-bottom: 14px; display: flex; gap: 12px; flex-wrap: wrap; }
.cv-watch-overview { color: #ddd; line-height: 1.6; font-size: 15px; margin-bottom: 24px; }
.cv-genre-tag {
  display: inline-block;
  background: rgba(255,255,255,0.08);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  margin: 0 6px 6px 0;
  color: #ccc;
}

/* ---------- Episode picker (TV) ---------- */
.cv-episode-picker {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 18px 0 26px;
  padding: 16px;
  background: #1c1c1c;
  border-radius: 8px;
}
.cv-episode-picker select {
  background: #262626;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 14px;
}
.cv-episode-picker button {
  background: #e50914;
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

/* ---------- Embed share box ---------- */
.cv-embed-box {
  background: #1c1c1c;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 18px 20px;
  margin-top: 10px;
}
.cv-embed-box h3 { margin: 0 0 4px; font-size: 15px; }
.cv-embed-box p.cv-embed-sub { margin: 0 0 14px; color: #999; font-size: 13px; }
.cv-embed-row { display: flex; gap: 8px; margin-bottom: 10px; }
.cv-embed-row input, .cv-embed-row textarea {
  flex: 1;
  background: #111;
  color: #ddd;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: 9px 10px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.cv-embed-row textarea { resize: vertical; min-height: 60px; }
.cv-copy-btn {
  background: #333;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.cv-copy-btn.cv-copied { background: #2ea043; }

/* ---------- Mobile tuning ---------- */
@media (max-width: 640px) {
  .cv-nav { padding: 10px 14px; }
  .cv-brand { font-size: 18px; }
  .cv-search-form { max-width: none; }
  .cv-hero { height: 78vw; min-height: 280px; }
  .cv-hero-content { left: 14px; right: 14px; bottom: 24px; }
  .cv-row-title { padding: 0 14px; font-size: 15px; }
  .cv-row-scroll { padding: 4px 14px 10px; }
  .cv-card { width: 104px; }
  .cv-page-pad { padding: 78px 14px 40px; }
  .cv-watch-info { padding: 16px 14px 32px; }
  .cv-watch-play-btn { width: 66px; height: 66px; }
  .cv-embed-row { flex-direction: column; }
  .cv-copy-btn { padding: 10px; }
}
