:root {
  --bg: #080a0f;
  --panel: #11141c;
  --panel-2: #181c26;
  --text: #f6f7fb;
  --muted: #939aaa;
  --primary: #e50914;
  --primary-2: #ff3340;
  --border: rgba(255, 255, 255, .09);
  --success: #3ddc97;
  --warning: #ffb020;
  --danger: #ff4757;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top, #171b27 0, var(--bg) 38rem);
  color: var(--text);
  font-family:
    system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  min-height: 100vh;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: 64px;
  padding: 10px 4%;
  display: flex;
  align-items: center;
  gap: 18px;
  background: rgba(8, 10, 15, .88);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(18px);
}

.brand {
  border: 0;
  background: transparent;
  font-size: 21px;
  font-weight: 900;
  letter-spacing: 1px;
  cursor: pointer;
  padding: 0;
}

.brand-mark {
  color: var(--primary);
}

.nav {
  display: flex;
  gap: 6px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar {
  display: none;
}

.nav button,
.filter-button {
  white-space: nowrap;
  border: 0;
  border-radius: 999px;
  padding: 9px 13px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.nav button:hover,
.nav button.active,
.filter-button.active {
  background: var(--panel-2);
  color: white;
}

.icon-button,
.favorite-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel);
  display: grid;
  place-items: center;
  cursor: pointer;
}

svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#app {
  width: min(1180px, 92%);
  margin: 0 auto;
  padding: 24px 0 80px;
}

.hero {
  min-height: 300px;
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 36px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(8,10,15,.96), rgba(8,10,15,.32)),
    var(--hero-image) center/cover;
  margin-bottom: 28px;
}

.hero-content {
  max-width: 650px;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 6vw, 56px);
}

.hero p,
.muted {
  color: var(--muted);
}

.section-header,
.admin-toolbar,
.form-actions,
.detail-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.section-header {
  margin-bottom: 18px;
}

.section-header h1,
.section-header h2 {
  margin: 0;
}

.search-input,
.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0c0f16;
  color: white;
  padding: 12px 14px;
  outline: none;
}

.search-input {
  width: min(100%, 360px);
}

.search-input:focus,
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: rgba(229, 9, 20, .8);
  box-shadow: 0 0 0 3px rgba(229, 9, 20, .12);
}

.movie-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.movie-card {
  min-width: 0;
  cursor: pointer;
}

.poster-wrap {
  position: relative;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
}

.poster-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .25s ease;
}

.movie-card:hover img {
  transform: scale(1.035);
}

.card-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .75);
  font-size: 11px;
  font-weight: 800;
}

.movie-card h3 {
  font-size: 15px;
  margin: 9px 2px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.movie-card p {
  margin: 0 2px;
  color: var(--muted);
  font-size: 12px;
}

.button {
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 750;
  background: var(--primary);
  color: white;
  cursor: pointer;
}

.button:hover {
  background: var(--primary-2);
}

.button.secondary {
  background: var(--panel-2);
  border: 1px solid var(--border);
}

.button.danger {
  background: var(--danger);
}

.button.small {
  padding: 8px 11px;
  font-size: 13px;
}

.detail-hero {
  min-height: 360px;
  display: flex;
  align-items: flex-end;
  padding: 32px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background:
    linear-gradient(0deg, var(--bg), rgba(8,10,15,.25)),
    var(--backdrop) center/cover;
}

.detail-content {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 24px;
  width: 100%;
  align-items: end;
}

.detail-poster {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--border);
}

.meta {
  color: var(--muted);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.episode-section {
  margin-top: 28px;
}

.episode-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 16px;
  scroll-snap-type: x mandatory;
}

.episode-button {
  flex: 0 0 150px;
  min-height: 82px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  text-align: left;
  padding: 12px;
  cursor: pointer;
  scroll-snap-align: start;
}

.episode-button:hover {
  border-color: var(--primary);
}

.modal,
.player-modal {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--panel);
  color: white;
  width: min(94%, 520px);
  padding: 24px;
}

.player-modal {
  width: min(96%, 1000px);
}

.modal::backdrop,
.player-modal::backdrop {
  background: rgba(0, 0, 0, .82);
  backdrop-filter: blur(5px);
}

.modal-close,
.player-close {
  float: right;
  border: 0;
  background: transparent;
  font-size: 30px;
  cursor: pointer;
}

.player-title {
  font-weight: 800;
  padding: 7px 45px 15px 0;
}

#videoPlayer {
  display: block;
  width: 100%;
  max-height: 75vh;
  background: black;
  border-radius: 14px;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
}

.field textarea {
  min-height: 110px;
  resize: vertical;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.full {
  grid-column: 1 / -1;
}

.admin-card,
.loading-card,
.empty-card,
.maintenance-card {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}

.admin-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.admin-row {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.admin-row img {
  width: 54px;
  height: 72px;
  object-fit: cover;
  border-radius: 9px;
  background: #222;
}

.status-public {
  color: var(--success);
}

.status-draft {
  color: var(--warning);
}

.parser-preview {
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.parser-row {
  display: grid;
  grid-template-columns: 55px 60px 1fr;
  gap: 8px;
  padding: 9px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  transform: translate(-50%, 120px);
  opacity: 0;
  background: #f7f7fb;
  color: #080a0f;
  border-radius: 999px;
  padding: 11px 18px;
  transition: .25s;
  max-width: 90%;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (max-width: 680px) {
  .topbar {
    gap: 9px;
    padding-inline: 3%;
  }

  .brand {
    font-size: 17px;
  }

  .nav button {
    padding: 8px 10px;
    font-size: 12px;
  }

  #app {
    width: 94%;
    padding-top: 16px;
  }

  .movie-grid {
    gap: 8px;
  }

  .movie-card h3 {
    font-size: 12px;
  }

  .poster-wrap {
    border-radius: 11px;
  }

  .hero {
    min-height: 240px;
    padding: 22px;
  }

  .detail-hero {
    padding: 16px;
  }

  .detail-content {
    grid-template-columns: 100px 1fr;
    gap: 14px;
  }

  .detail-content h1 {
    font-size: 22px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .full {
    grid-column: auto;
  }

  .admin-row {
    grid-template-columns: 44px 1fr;
  }

  .admin-row img {
    width: 44px;
    height: 60px;
  }

  .admin-row-actions {
    grid-column: 1 / -1;
  }
}
/* ======================================================
   CMFLIX premium/mobile UI fixes
   Add this block at the END of style.css
   ====================================================== */

body {
  overflow-x: hidden;
}

#app {
  width: min(1240px, calc(100% - 40px));
}

/* ---------- Home hero ---------- */

.hero {
  min-height: clamp(320px, 48vw, 520px);
  position: relative;
  align-items: flex-end;
  padding: clamp(24px, 5vw, 58px);
  isolation: isolate;
  background:
    linear-gradient(
      90deg,
      rgba(5, 7, 11, .97) 0%,
      rgba(5, 7, 11, .76) 42%,
      rgba(5, 7, 11, .12) 100%
    ),
    linear-gradient(
      0deg,
      rgba(5, 7, 11, .95) 0%,
      transparent 58%
    ),
    var(--hero-image) center / cover no-repeat;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 35%;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(
      transparent,
      rgba(8, 10, 15, .68)
    );
}

.hero-content {
  width: min(650px, 100%);
}

.hero-kicker,
.detail-label {
  margin: 0 0 10px;
  color: #ff5360 !important;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1.8px;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(30px, 6vw, 58px);
  line-height: 1.04;
  letter-spacing: -.03em;
}

.hero-overview {
  margin: 0;
  max-width: 620px;
  line-height: 1.75;
  color: rgba(255, 255, 255, .76) !important;

  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.hero-actions {
  display: flex;
  margin-top: 20px;
}

/* ---------- Genre filters ---------- */

.genre-filter,
.detail-genres {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  padding: 1px 1px 18px;
  scrollbar-width: none;
}

.genre-filter::-webkit-scrollbar,
.detail-genres::-webkit-scrollbar,
.cast-scroll::-webkit-scrollbar,
.episode-scroll::-webkit-scrollbar {
  display: none;
}

.genre-chip {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 15px;
  background: rgba(17, 20, 28, .8);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.genre-chip:hover,
.genre-chip.active {
  border-color: rgba(229, 9, 20, .7);
  background: rgba(229, 9, 20, .15);
  color: white;
}

.genre-chip.static {
  cursor: default;
}

/* ---------- Movie grid ---------- */

.movie-grid {
  grid-template-columns:
    repeat(auto-fill, minmax(150px, 1fr));
  gap: 22px 15px;
}

.movie-card {
  transition:
    transform .2s ease,
    opacity .2s ease;
}

.movie-card:hover {
  transform: translateY(-4px);
}

.poster-wrap {
  box-shadow: 0 14px 32px rgba(0, 0, 0, .22);
}

.movie-card h3 {
  margin-top: 10px;
  font-size: 14px;
}

/* ---------- Detail page ---------- */

.detail-hero {
  min-height: clamp(420px, 55vw, 610px);
  position: relative;
  align-items: flex-end;
  overflow: hidden;
  padding: clamp(24px, 5vw, 54px);
  isolation: isolate;

  background:
    linear-gradient(
      90deg,
      rgba(5, 7, 11, .96) 0%,
      rgba(5, 7, 11, .72) 48%,
      rgba(5, 7, 11, .18) 100%
    ),
    linear-gradient(
      0deg,
      rgba(5, 7, 11, .98) 0%,
      rgba(5, 7, 11, .08) 70%
    ),
    var(--backdrop) center / cover no-repeat;
}

.detail-content {
  grid-template-columns: 180px minmax(0, 1fr);
  grid-template-areas:
    "poster main"
    "poster overview";
  align-items: end;
  gap: 16px 28px;
  max-width: 920px;
}

.detail-poster {
  grid-area: poster;
  width: 180px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  align-self: end;
  box-shadow: 0 18px 45px rgba(0, 0, 0, .48);
}

.poster-placeholder {
  display: grid;
  place-items: center;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
}

.detail-main {
  grid-area: main;
  min-width: 0;
}

.detail-main h1 {
  margin: 0 0 12px;
  max-width: 760px;
  font-size: clamp(30px, 5vw, 56px);
  line-height: 1.06;
  letter-spacing: -.03em;
}

.detail-main .meta {
  margin-bottom: 18px;
}

.detail-overview {
  grid-area: overview;
  min-width: 0;
}

.detail-overview h2 {
  margin: 0 0 8px;
  font-size: 15px;
}

.detail-overview p {
  margin: 0;
  max-width: 760px;
  color: rgba(255, 255, 255, .76);
  line-height: 1.78;
  white-space: pre-line;

  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  overflow: hidden;
}

.detail-actions {
  justify-content: flex-start;
  margin-bottom: 18px;
}

.detail-actions .button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.detail-actions .button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.detail-section {
  margin-top: 30px;
}

.detail-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
}

.detail-section-heading h2 {
  margin: 0;
  font-size: clamp(20px, 3vw, 27px);
}

/* ---------- Cast ---------- */

.cast-scroll {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 2px 2px 16px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

.cast-card {
  flex: 0 0 112px;
  min-width: 0;
  scroll-snap-align: start;
}

.cast-card img,
.cast-placeholder {
  width: 112px;
  height: 148px;
  border: 1px solid var(--border);
  border-radius: 15px;
  object-fit: cover;
  display: block;
  background: var(--panel);
}

.cast-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 34px;
  font-weight: 800;
}

.cast-card strong {
  display: block;
  margin-top: 9px;
  overflow: hidden;
  color: white;
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cast-card span {
  display: -webkit-box;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* ---------- Episodes ---------- */

.episode-section {
  margin-top: 30px;
}

.episode-button {
  display: grid;
  gap: 5px;
  flex-basis: 170px;
}

.episode-button .muted {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Full-size video player ---------- */

.player-modal {
  position: fixed;
  inset: 0;
  width: min(1100px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 22px;
  overflow: hidden;
}

.player-modal[open] {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.player-close {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 5;
  width: 42px;
  height: 42px;
  float: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
}

.player-title {
  flex: 0 0 auto;
  min-height: 45px;
  padding: 5px 52px 14px 0;
  font-size: 17px;
}

#videoPlayer {
  width: 100%;
  height: auto;
  max-height: calc(100dvh - 110px);
  aspect-ratio: 16 / 9;
  object-fit: contain;
  border-radius: 14px;
  background: #000;
}

#videoPlayer:fullscreen,
#videoPlayer:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-height: none;
  border-radius: 0;
  object-fit: contain;
  background: #000;
}

/* ---------- Tablet ---------- */

@media (max-width: 820px) {
  #app {
    width: min(100% - 28px, 1240px);
  }

  .hero {
    min-height: 390px;
  }

  .detail-content {
    grid-template-columns: 145px minmax(0, 1fr);
  }

  .detail-poster {
    width: 145px;
  }
}

/* ---------- Mobile ---------- */

@media (max-width: 680px) {
  #app {
    width: calc(100% - 24px);
    padding-top: 12px;
    padding-bottom: 50px;
  }

  .topbar {
    min-height: 60px;
  }

  .hero {
    min-height: 360px;
    margin-bottom: 24px;
    padding: 24px 20px;
    border-radius: 20px;

    background:
      linear-gradient(
        0deg,
        rgba(5, 7, 11, .98) 0%,
        rgba(5, 7, 11, .72) 48%,
        rgba(5, 7, 11, .12) 100%
      ),
      var(--hero-image) center / cover no-repeat;
  }

  .hero h1 {
    font-size: 31px;
  }

  .hero-overview {
    font-size: 14px;
    line-height: 1.7;
    -webkit-line-clamp: 3;
  }

  .section-header {
    align-items: stretch;
  }

  .section-header h1,
  .section-header h2 {
    width: 100%;
  }

  .search-input {
    width: 100%;
    max-width: none;
  }

  .movie-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 10px;
  }

  .movie-card h3 {
    font-size: 13px;
  }

  .movie-card p {
    font-size: 11px;
  }

  .detail-hero {
    min-height: 0;
    padding: 190px 18px 22px;
    border-radius: 20px;

    background:
      linear-gradient(
        0deg,
        rgba(5, 7, 11, .99) 0%,
        rgba(5, 7, 11, .93) 42%,
        rgba(5, 7, 11, .15) 100%
      ),
      var(--backdrop) top center / 100% auto no-repeat;
  }

  .detail-content {
    grid-template-columns: 92px minmax(0, 1fr);
    grid-template-areas:
      "poster main"
      "overview overview";
    align-items: start;
    gap: 17px 15px;
  }

  .detail-poster {
    width: 92px;
    border-radius: 12px;
    align-self: start;
  }

  .detail-main h1 {
    margin-bottom: 9px;
    font-size: 23px;
    line-height: 1.12;
  }

  .detail-label {
    margin-bottom: 7px;
  }

  .detail-main .meta {
    gap: 6px 10px;
    margin-bottom: 13px;
    font-size: 12px;
  }

  .detail-actions {
    gap: 8px;
    margin: 0;
  }

  .detail-actions .button {
    min-height: 40px;
    padding: 9px 12px;
    font-size: 13px;
  }

  .detail-actions .button svg {
    width: 18px;
    height: 18px;
  }

  .detail-overview {
    width: 100%;
    padding-top: 5px;
  }

  .detail-overview p {
    font-size: 14px;
    line-height: 1.75;
    -webkit-line-clamp: 6;
  }

  .detail-section {
    margin-top: 25px;
  }

  .cast-card {
    flex-basis: 94px;
  }

  .cast-card img,
  .cast-placeholder {
    width: 94px;
    height: 128px;
    border-radius: 13px;
  }

  .player-modal {
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding:
      max(12px, env(safe-area-inset-top))
      12px
      max(12px, env(safe-area-inset-bottom));
    border: 0;
    border-radius: 0;
    background: #000;
  }

  .player-modal::backdrop {
    background: #000;
  }

  .player-title {
    position: absolute;
    top: max(10px, env(safe-area-inset-top));
    left: 16px;
    right: 58px;
    z-index: 4;
    padding: 8px 0;
    text-shadow: 0 2px 8px #000;
  }

  .player-close {
    top: max(8px, env(safe-area-inset-top));
    right: 10px;
  }

  #videoPlayer {
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    object-fit: contain;
  }
}

/* Mobile landscape video */

@media (
  max-width: 920px
) and (
  orientation: landscape
) {
  .player-title {
    font-size: 14px;
  }

  #videoPlayer {
    width: 100%;
    height: 100%;
    max-height: 100dvh;
  }
}

