/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #141414;
  --bg-card:   #1e1e1e;
  --accent:    #e50914;
  --text:      #e5e5e5;
  --text-dim:  #999;
  --header-h:  68px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Header ── */
.header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 200;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4%;
  background: linear-gradient(to bottom, rgba(0,0,0,.85) 0%, transparent 100%);
  transition: background .3s;
}
.header.solid { background: rgba(20,20,20,.97); }

.header-left { display: flex; align-items: center; gap: 32px; }

.logo {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -.5px;
  cursor: default;
  user-select: none;
}

.search {
  background: rgba(0,0,0,.55);
  border: 1px solid rgba(255,255,255,.25);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 4px;
  font-size: .85rem;
  width: 220px;
  transition: width .3s, border-color .2s;
}
.search:focus {
  outline: none;
  border-color: rgba(255,255,255,.65);
  width: 280px;
}
.search::placeholder { color: var(--text-dim); }

/* ── Hero ── */
.hero {
  position: relative;
  height: min(56vw, 82vh);
  min-height: 380px;
  overflow: hidden;
}
.hero.hidden { display: none; }

.hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center top;
  filter: brightness(.45);
  transform: scale(1.04);
  transition: transform 8s ease;
}
.hero:hover .hero-bg { transform: scale(1.06); }

.hero-vignette {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to right,  rgba(20,20,20,.92) 0%, rgba(20,20,20,.3) 55%, transparent 100%),
    linear-gradient(to top,    rgba(20,20,20,.9)  0%, transparent 60%),
    linear-gradient(to bottom, rgba(20,20,20,.5)  0%, transparent 30%);
}

.hero-content {
  position: absolute;
  bottom: 22%;
  left: 4%;
  max-width: 42%;
}

.hero-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 3px;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.hero-title {
  font-size: clamp(1.4rem, 3.5vw, 2.8rem);
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 14px;
  text-shadow: 1px 2px 6px rgba(0,0,0,.6);
}

.hero-desc {
  font-size: clamp(.78rem, 1.1vw, .97rem);
  color: #ccc;
  line-height: 1.55;
  margin-bottom: 22px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-actions { display: flex; gap: 12px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 26px;
  border-radius: 4px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .2s, transform .1s;
}
.btn:hover { transform: scale(1.04); opacity: .92; }

.btn-play  { background: #fff;                   color: #000; }
.btn-info  { background: rgba(109,109,110,.7);   color: #fff; }

/* ── Content area ── */
#content { padding-bottom: 48px; }

/* ── Channel row ── */
.channel-row {
  margin-bottom: 2.8rem;
  padding: 0 4%;
}

.row-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.row-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.row-count {
  font-size: .78rem;
  color: var(--text-dim);
}

.row-wrap {
  position: relative;
}

.row-scroll {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 6px 0 14px;
}
.row-scroll::-webkit-scrollbar { display: none; }

.row-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-60%);
  z-index: 10;
  background: rgba(20,20,20,.85);
  border: 1px solid rgba(255,255,255,.15);
  color: #fff;
  width: 38px;
  height: 64px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, background .2s;
}
.row-wrap:hover .row-btn { opacity: 1; pointer-events: all; }
.row-btn:hover { background: rgba(50,50,50,.95); }
.row-btn.left  { left: -19px; }
.row-btn.right { right: -19px; }

/* ── Video card ── */
.card {
  flex: 0 0 calc(20% - 6px);
  min-width: 180px;
  max-width: 300px;
  border-radius: 4px;
  overflow: visible;
  cursor: pointer;
  transition: transform .25s ease;
  position: relative;
}
.card:hover {
  transform: scale(1.07);
  z-index: 20;
}

.card-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #2a2a2a;
  border-radius: 4px;
  overflow: hidden;
}

.card-new-badge {
  position: absolute;
  top: 7px;
  left: 7px;
  z-index: 5;
  background: #2ecc71;
  color: #000;
  font-size: .58rem;
  font-weight: 800;
  letter-spacing: .08em;
  padding: 2px 7px;
  border-radius: 3px;
  pointer-events: none;
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: filter .25s;
}
.card:hover .card-thumb img { filter: brightness(.65); }

.card-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .25s;
}
.card:hover .card-overlay { opacity: 1; }

.play-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,.9);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,.5);
}
.play-icon svg { width: 20px; height: 20px; fill: #000; margin-left: 3px; }

.card-info {
  padding: 8px 4px 0;
}

.card-title {
  font-size: .78rem;
  font-weight: 500;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text);
}

.card-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: .68rem;
  color: var(--text-dim);
}

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.82);
}

.modal-box {
  position: relative;
  width: 100%;
  max-width: 920px;
  max-height: 92vh;
  overflow-y: auto;
  background: #181818;
  border-radius: 8px;
  box-shadow: 0 12px 50px rgba(0,0,0,.85);
}
.modal-box::-webkit-scrollbar { width: 6px; }
.modal-box::-webkit-scrollbar-track { background: #111; }
.modal-box::-webkit-scrollbar-thumb { background: #3a3a3a; border-radius: 3px; }

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  background: rgba(0,0,0,.65);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: .95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
}
.modal-close:hover { background: rgba(70,70,70,.9); }

.modal-player {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
}
.modal-player iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.modal-info { padding: 20px 24px 24px; }

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 10px;
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: .82rem;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.modal-meta .m-channel { color: #4fc3f7; font-weight: 600; }
.modal-meta .m-views   { color: #a5d6a7; }

.modal-desc {
  font-size: .88rem;
  color: #bbb;
  line-height: 1.65;
  white-space: pre-line;
}

/* ── Search results ── */
.search-section {
  padding: calc(var(--header-h) + 24px) 4% 48px;
}
.search-heading {
  font-size: 1rem;
  color: var(--text-dim);
  margin-bottom: 18px;
}
.search-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.search-grid .card { flex: none; max-width: none; width: 100%; }

/* ── Loading ── */
.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  z-index: 900;
}
.loading-screen.hidden { display: none; }

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
.loading-screen p { color: var(--text-dim); font-size: .9rem; }

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

/* ── Error notice ── */
.error-notice {
  background: rgba(229,9,20,.15);
  border: 1px solid rgba(229,9,20,.4);
  border-radius: 6px;
  padding: 10px 16px;
  font-size: .82rem;
  color: #f88;
  margin: 0 4% 1rem;
}

/* ── Settings panel ── */
.settings-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 6px 8px;
  opacity: .7;
  transition: opacity .2s;
  line-height: 1;
  margin-left: 6px;
}
.settings-btn:hover { opacity: 1; }

.settings-panel {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.settings-panel.hidden { display: none; }

.settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.82);
}

.settings-box {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: 80vh;
  background: #181818;
  border-radius: 8px;
  box-shadow: 0 12px 50px rgba(0,0,0,.85);
  display: flex;
  flex-direction: column;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #2a2a2a;
  flex-shrink: 0;
}

.settings-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.settings-add {
  display: flex;
  gap: 8px;
  padding: 16px 24px;
  flex-shrink: 0;
}

.handle-input {
  flex: 1;
  background: #2a2a2a;
  border: 1px solid rgba(255,255,255,.15);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: .88rem;
}
.handle-input:focus { outline: none; border-color: rgba(255,255,255,.4); }
.handle-input::placeholder { color: var(--text-dim); }
.handle-input.input-error { border-color: var(--accent); }
.btn-add:disabled { opacity: .5; cursor: default; }

.btn-add { background: var(--accent); color: #fff; }

.settings-channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 24px;
  scrollbar-width: thin;
  scrollbar-color: #3a3a3a transparent;
}
.settings-channel-list::-webkit-scrollbar { width: 4px; }
.settings-channel-list::-webkit-scrollbar-thumb { background: #3a3a3a; border-radius: 2px; }

.settings-channel-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #242424;
  font-size: .88rem;
}
.settings-channel-item:last-child { border-bottom: none; }

.settings-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: .85rem;
  padding: 4px 8px;
  border-radius: 3px;
  transition: color .15s, background .15s;
}
.settings-remove:hover { color: #fff; background: rgba(229,9,20,.45); }

.settings-empty {
  color: var(--text-dim);
  font-size: .85rem;
  padding: 20px 0;
  text-align: center;
}

.settings-info {
  font-size: .76rem;
  color: var(--text-dim);
  padding: 10px 24px 14px;
  flex-shrink: 0;
  line-height: 1.5;
}

.settings-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 8px;
}

.settings-footer-left {
  display: flex;
  gap: 8px;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .card { flex: 0 0 calc(25% - 6px); }
}
@media (max-width: 680px) {
  .card { flex: 0 0 calc(33.333% - 5px); min-width: 140px; }
  .hero-content { max-width: 80%; }
  .search { width: 170px; }
  .search:focus { width: 220px; }
}
@media (max-width: 440px) {
  .card { flex: 0 0 calc(50% - 4px); }
  .hero-content { max-width: 95%; }
  .header { padding: 0 3%; }
  .channel-row { padding: 0 3%; }
}
