:root {
  --bg: #0d1017;
  --panel: #161b26;
  --panel2: #1e2534;
  --text: #e8ebf2;
  --dim: #8b93a7;
  --accent: #6c8cff;
  --danger: #ff5d6c;
  --ok: #3ecf8e;
  --radius: 14px;
  --main-pad-x: clamp(1rem, 3vw, 2.5rem);
  --main-pad-top: 1.5rem;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #2a3245; border-radius: 4px; }
html::-webkit-scrollbar, body::-webkit-scrollbar { display: none; }
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { display: none !important; }
a { color: inherit; text-decoration: none; }


button {
  font: inherit; color: inherit; background: var(--panel2);
  border: 1px solid #2a3245; border-radius: 10px;
  padding: .5rem .9rem; cursor: pointer; transition: all .2s;
}
button:hover { border-color: var(--accent); transform: translateY(-1px); }
button.primary { background: var(--accent); border-color: var(--accent); color: #0b0e14; font-weight: 600; }
button.ghost { background: transparent; }
button:disabled { opacity: .4; cursor: default; transform: none; }

input, select {
  font: inherit; color: var(--text); background: var(--panel2);
  border: 1px solid #2a3245; border-radius: 10px;
  padding: .5rem .7rem; outline: none; transition: border-color .2s;
}
input:focus, select:focus { border-color: var(--accent); }

/* ---------- layout ---------- */
#app { display: flex; min-height: 100vh; }
#sidebar {
  width: 220px; flex-shrink: 0; position: sticky; top: 0; height: 100vh;
  padding: 1.2rem .8rem; display: flex; flex-direction: column; gap: .25rem;
  background: var(--panel); border-right: 1px solid #202839;
}
#sidebar .logo { font-size: 1.25rem; font-weight: 800; letter-spacing: .5px; padding: 0 .8rem 1rem; color: var(--accent); }
#sidebar a { padding: .6rem .8rem; border-radius: 10px; color: var(--dim); font-weight: 500; transition: all .2s; }
#sidebar a.active, #sidebar a:hover { background: var(--panel2); color: var(--text); }
#sidebar a {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: .7;
  transition: opacity .2s;
}

#sidebar a:hover .nav-icon,
#sidebar a.active .nav-icon {
  opacity: 1;
}
#main { flex: 1; min-width: 0; padding: var(--main-pad-top) var(--main-pad-x) 4rem; }

.page-head { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-bottom: 1rem; }
.page-head h1 { font-size: 1.5rem; margin-right: auto; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.2rem; }
.search-input { min-width: 220px; }

/* ---------- grid cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.card { cursor: pointer; transition: transform .2s; display: flex; flex-direction: column; }
.card:hover { transform: translateY(-4px); }
.poster {
  aspect-ratio: 2/3; border-radius: var(--radius);
  background-color: var(--panel2); background-size: cover; background-position: center;
  position: relative; box-shadow: 0 4px 14px rgba(0,0,0,.35); overflow: hidden;
}
.badge { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.7); border-radius: 8px; padding: 2px 7px; font-size: .75rem; }
.wdot { position: absolute; top: 8px; left: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.reset-watched-btn {
  position: absolute; bottom: 6px; right: 6px;
  width: 26px; height: 26px; border-radius: 7px;
  background: rgba(0,0,0,.8); border: 1px solid rgba(255,255,255,.2);
  color: #fff; font-size: .95rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0; opacity: 0;
  transition: opacity .2s, background .2s, border-color .2s;
  z-index: 2;
}
.card:hover .reset-watched-btn, .media-card:hover .reset-watched-btn { opacity: 1; }
.reset-watched-btn:hover { background: var(--accent); border-color: var(--accent); color: #0b0e14; }
/* On the big detail-page posters (not tiny hover grid tiles) the button is
   always visible — there's no hover affordance to discover it otherwise. */
.watch-poster .reset-watched-btn, .d-poster .reset-watched-btn {
  opacity: 1; top: 8px; right: 8px; bottom: auto; left: auto;
  width: 30px; height: 30px; font-size: 1.05rem;
}
.card-title { margin-top: .45rem; font-weight: 600; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-sub { color: var(--dim); font-size: .78rem; }

.sentinel { display: flex; justify-content: center; align-items: center; padding: 2rem; color: var(--dim); min-height: 60px; }
.spin { width: 22px; height: 22px; border: 3px solid #2a3245; border-top-color: var(--accent); border-radius: 50%; animation: sp 1s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ---------- horizontal rows ---------- */
.hrow {
  display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .3rem;
  scrollbar-width: none; -ms-overflow-style: none;
}
.hrow::-webkit-scrollbar { display: none; }
.hrow .card { flex: 0 0 140px; }

/* ---------- hero banner ----------  */
.hero-banner {
  width: calc(100% + var(--main-pad-x) * 2);
  margin: calc(var(--main-pad-top) * -1) calc(var(--main-pad-x) * -1) 2.5rem;
  min-height: 480px;
  overflow: hidden; 
  position: relative;
  background: linear-gradient(135deg, #1a1f2e 0%, #0d1017 100%);
  border-radius: 0 0 24px 24px; /* Soft bottom corners */
  box-shadow: 0 20px 28px -14px rgba(0,0,0,0.6);
}

.hero-loading, .hero-empty, .hero-error {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 480px; gap: 1rem; color: var(--dim);
}

.hero-carousel { position: relative; height: 480px; }
.hero-slides { position: relative; width: 100%; height: 100%; }

.hero-slide {
  position: absolute; inset: 0;
  opacity: 0;
  transition: opacity 1.2s ease-in-out;
  pointer-events: none;
  overflow: hidden; /* clip the zoomed background so it never spills */
}

.hero-slide.active {
  opacity: 1;
  pointer-events: auto;
}

/* Background layer — the ONLY thing that zooms */
.hero-bg {
  position: absolute; inset: 0;
  background-size: cover;
  background-position: center top;
  transform: scale(1.05) translateZ(0); /* translateZ(0) forces GPU hardware acceleration */
  will-change: transform;
  backface-visibility: hidden;
}

/* Stop animations entirely if the user has battery-saver/reduced-motion on */
@media (prefers-reduced-motion: reduce) {
  .hero-slide.active .hero-bg { 
    animation: none !important; 
    transform: scale(1.05) translateZ(0); 
  }
}

.hero-slide.active .hero-bg {
  animation: kenburns 20s ease-in-out infinite alternate;
}

@keyframes kenburns {
  0% { transform: scale(1.05) translate(0, 0); }
  100% { transform: scale(1.15) translate(-1%, -1%); }
}

.hero-overlay { z-index: 1; }   /* make sure overlay sits above the bg */
.hero-content { z-index: 2; }   /* and content stays on top, unmoved */

.hero-overlay {
  position: absolute; inset: 0;
  background: 
    /* Left-to-right dark fade for text readability */
    linear-gradient(90deg, rgba(13,16,23,0.95) 0%, rgba(13,16,23,0.7) 35%, rgba(13,16,23,0.1) 70%, transparent 100%),
    /* Bottom vignette to blend into the page seamlessly */
    linear-gradient(0deg, rgba(13,16,23,0.8) 0%, transparent 40%),
    /* Top subtle darkening for depth */
    linear-gradient(180deg, rgba(13,16,23,0.4) 0%, transparent 20%);
}

.hero-content {
  position: relative; z-index: 2; 
  padding: 3rem var(--main-pad-x); 
  height: 100%;
  display: flex; flex-direction: column; justify-content: center;
  max-width: 650px;
  animation: fadeSlideUp 0.8s ease-out forwards;
}

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

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: linear-gradient(135deg, var(--accent), #8ba6ff);
  color: #0b0e14;
  padding: .35rem .9rem; 
  border-radius: 6px; 
  font-size: .75rem; 
  font-weight: 800;
  text-transform: uppercase; 
  letter-spacing: .8px; 
  margin-bottom: 1rem; 
  width: fit-content;
  box-shadow: 0 4px 12px rgba(108,140,255,0.3);
}

.hero-title {
  font-size: 2.8rem; 
  font-weight: 900; 
  margin-bottom: .8rem; 
  line-height: 1.1;
  letter-spacing: -0.5px;
  text-shadow: 0 4px 12px rgba(0,0,0,0.8), 0 2px 4px rgba(0,0,0,0.5);
  overflow: hidden; 
  text-overflow: ellipsis; 
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.hero-meta { 
  display: flex; 
  align-items: center;
  gap: 1.2rem; 
  margin-bottom: 1rem; 
  color: #d0d6e4; 
  font-size: .95rem;
  font-weight: 500;
  text-shadow: 0 2px 4px rgba(0,0,0,0.6);
}

.hero-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.hero-desc {
  color: #c3c9d6; 
  margin-bottom: 1.5rem; 
  font-size: 1rem; 
  line-height: 1.6;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
  display: -webkit-box; 
  -webkit-line-clamp: 3; 
  -webkit-box-orient: vertical; 
  overflow: hidden;
  max-width: 550px;
}

.hero-actions {
  display: flex;
  gap: 0.8rem;
  align-items: center;
}

.hero-btn {
  background: var(--accent); 
  color: #0b0e14; 
  border: none;
  padding: .8rem 2rem; 
  border-radius: 12px; 
  font-size: 1rem; 
  font-weight: 700;
  cursor: pointer; 
  width: fit-content; 
  transition: all .25s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 15px rgba(108,140,255,0.4);
}

.hero-btn:hover { 
  transform: translateY(-3px) scale(1.02); 
  box-shadow: 0 8px 25px rgba(108,140,255,0.6); 
}

.hero-btn.ghost {
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(8px);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow: none;
}

.hero-btn.ghost:hover {
  background: rgba(255,255,255,0.25);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.hero-dots { 
  position: absolute; 
  bottom: 1.5rem; 
  right: calc(var(--main-pad-x)); 
  display: flex; 
  gap: .6rem; 
  z-index: 3; 
}

.hero-dot { 
  width: 8px; 
  height: 8px;  
  border-radius: 50%; 
  background: rgba(255,255,255,0.3); 
  cursor: pointer; 
  transition: all .4s cubic-bezier(0.4, 0, 0.2, 1); 
}

.hero-dot:hover { 
  background: rgba(255,255,255,0.6); 
  transform: scale(1.2);
}

.hero-dot.active { 
  background: var(--accent); 
  width: 24px; 
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(108,140,255,0.5);
}

/* Progress bar for auto-advance.
   Fills with a smooth GPU-friendly scaleX animation instead of JS width
   updates. The 8s duration IS the slide time — the JS advances the slide
   when this animation ends (see renderCarousel in app.js). */
.hero-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--accent);
  z-index: 4;
  box-shadow: 0 0 8px var(--accent);
  transform-origin: left center;
  transform: scaleX(0);
  animation: heroProgress 8s linear forwards;
}
@keyframes heroProgress {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}
/* Hovering the banner pauses the fill (and the auto-advance) */
.hero-progress.paused {
  animation-play-state: paused;
}

@media (max-width: 860px) {
  .hero-banner, .hero-carousel { min-height: 380px; height: 380px; }
  .hero-content { padding: 2rem var(--main-pad-x); max-width: 100%; }
  .hero-title { font-size: 1.8rem; }
  .hero-desc { font-size: .9rem; -webkit-line-clamp: 2; }
  .hero-btn { padding: .7rem 1.4rem; font-size: .9rem; }
  .hero-dots { bottom: 1rem; right: 1.5rem; gap: .5rem; }
}

/* ---------- home rows ---------- */
.home-page { display: flex; flex-direction: column; gap: 2rem; }
.content-row { display: flex; flex-direction: column; gap: 1rem; }
.row-header { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.row-header h2 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.see-all-link { color: var(--accent); font-size: .9rem; text-decoration: none; transition: opacity .2s; cursor: pointer; }
.see-all-link:hover { opacity: .8; }

/* Trending/genre rows scroll horizontally, same as Continue Watching,
   instead of wrapping into a grid that grows downward. */
.row-wrap { position: relative; }
.row-scroll {
  display: flex; gap: 1rem; overflow-x: auto; overflow-y: hidden;
  padding: .25rem .25rem .5rem; scroll-behavior: smooth;
  scrollbar-width: none; -ms-overflow-style: none;
  scroll-snap-type: x mandatory;
}
.row-scroll::-webkit-scrollbar { display: none; }
.row-scroll .media-card { flex: 0 0 160px; width: 160px; scroll-snap-align: start; }
.row-empty { padding: 2rem; color: var(--dim); }

/* Still used by the search page's "all results" fan-out rows. */
.row-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.row-grid .row-empty { grid-column: 1 / -1; text-align: center; }

.media-card { cursor: pointer; transition: transform .2s; display: flex; flex-direction: column; }
.media-card:hover { transform: translateY(-4px); }
.card-poster {
  aspect-ratio: 2/3; border-radius: 12px; overflow: hidden;
  background: var(--panel2); position: relative; box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
.card-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 3rem; background: var(--panel2); }
.card-info { padding: .6rem 0; }
.card-info .card-title { font-size: .95rem; font-weight: 600; margin: 0 0 .3rem 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { display: flex; gap: .8rem; font-size: .8rem; color: var(--dim); }

/* ---------- skeleton loading ---------- */
.media-card.skeleton { pointer-events: none; }
.media-card.skeleton .card-poster {
  background: linear-gradient(90deg, var(--panel2) 0%, #2a3245 50%, var(--panel2) 100%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite;
}
.skeleton-line {
  height: .9rem; border-radius: 4px; margin-bottom: .4rem;
  background: linear-gradient(90deg, var(--panel2) 0%, #2a3245 50%, var(--panel2) 100%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite;
}
.skeleton-line.short { width: 60%; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; background: rgba(5,8,14,.8); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 1.5rem; z-index: 50; }
.sheet { width: min(1000px, 100%); max-height: 100%; overflow-y: auto; background: var(--panel);
  border: 1px solid #232c3f; border-radius: 18px; padding: 1.5rem; position: relative; }
.sheet .close-x { position: absolute; top: .8rem; right: .8rem; z-index: 2; }
.d-hero { display: flex; gap: 1.4rem; flex-wrap: wrap; align-items: flex-start; }
.d-hero .d-poster { position: relative; flex: 0 0 200px; aspect-ratio: 2/3; border-radius: var(--radius);
  background-size: cover; background-position: center; background-color: var(--panel2); }
.d-info { flex: 1; min-width: 260px; }
.d-info h2 { font-size: 1.6rem; margin-bottom: .3rem; }
.d-meta { color: var(--dim); font-size: .88rem; margin-bottom: .7rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.chip { background: var(--panel2); border-radius: 99px; padding: 2px 10px; font-size: .75rem; color: var(--dim); }
.d-overview { color: #c3c9d6; margin-bottom: 1.1rem; max-width: 70ch; }
.d-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1.2rem; }
.src-select { min-width: 200px; }

.ep-list { display: flex; flex-direction: column; gap: .35rem; margin-top: .6rem; }
.ep-row { display: flex; align-items: center; gap: .7rem; background: var(--panel2);
  border-radius: 10px; padding: .5rem .8rem; cursor: pointer; transition: outline .2s; }
.ep-row:hover { outline: 1px solid var(--accent); }
.ep-row .ep-num { color: var(--dim); min-width: 2.6rem; font-variant-numeric: tabular-nums; }
.ep-row .ep-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ep-row .tick { color: var(--ok); }
.subhead { display: flex; gap: .6rem; align-items: center; margin-top: 1rem; flex-wrap: wrap; }
.subhead h3 { margin-right: auto; }

/* ---------- player ---------- */
.p-ov {
  background: rgba(3,5,9,.98);
  padding: 0;
  display: flex;
  flex-direction: column;
  /* Force the player overlay to fill the entire screen */
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  border-radius: 0 !important;
}

.p-bar {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap; /* fallback for narrow phone widths; shouldn't trigger otherwise now */
  padding: .4rem .6rem;
  background: var(--panel);
  border-bottom: 1px solid #232c3f;
  flex-shrink: 0; /* Prevents the top bar from getting squished */
  min-height: 0;
}

.p-bar .p-title {
  font-weight: 600;
  font-size: .85rem;
  margin-right: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 40vw;
}

.p-bar select {
  padding: .3rem .5rem;
  font-size: .82rem;
  max-width: 9rem;
}

/* Compact square icon buttons for the player bar (back, prev/next, open in
   new tab) so the bar reads as a thin strip of controls instead of a row of
   full-width text buttons. */
.p-bar .icon-btn {
  width: 2rem;
  height: 2rem;
  padding: 0;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

.p-frame {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0; /* Crucial for iframes inside flexbox containers */
  border: 0;
  background: #000;
}

.p-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  text-align: center;
  padding: 2rem;
}

/* ---------- reader ---------- */
.r-ov { background: #000; padding: 0; display: flex; flex-direction: column; }
.r-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.r-scroll img { display: block; width: 100%; max-width: 980px; margin: 0 auto; background: #111; }
.r-bar { display: flex; align-items: center; gap: .6rem; padding: .6rem .9rem;
  background: var(--panel); border-top: 1px solid #232c3f; flex-wrap: wrap; }
.r-bar .r-title { margin-right: auto; font-size: .9rem; max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- settings ---------- */
.settings { display: flex; flex-direction: column; gap: 1.5rem; max-width: 860px; }
.section { background: var(--panel); border: 1px solid #232c3f; border-radius: 16px; padding: 1.2rem; }
.section h3 { margin-bottom: .8rem; }
.form-grid { display: flex; flex-direction: column; gap: .6rem; }
.form-grid label { font-size: .82rem; color: var(--dim); }
.checks { display: flex; gap: .9rem; flex-wrap: wrap; }
.checks label { display: flex; gap: .35rem; align-items: center; color: var(--text); font-size: .9rem; }
.hint { color: var(--dim); font-size: .78rem; }
code { background: var(--panel2); padding: 1px 6px; border-radius: 6px; font-size: .8rem; }
.pv-row { display: flex; align-items: center; gap: .7rem; background: var(--panel2);
  border-radius: 12px; padding: .7rem .9rem; margin-top: .6rem; flex-wrap: wrap; }
.pv-row .pv-name { font-weight: 600; margin-right: auto; }
.pv-row .chip { margin: 0; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .4rem; }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid #2a3245; border-radius: 12px;
  padding: .65rem 1.1rem; z-index: 200; box-shadow: 0 6px 24px rgba(0,0,0,.5); max-width: 90vw; }

/* ---------- search tabs ---------- */
.tabs { display: flex; gap: .5rem; margin: 1.2rem 0; flex-wrap: wrap; border-bottom: 1px solid #232c3f; padding-bottom: 1rem; }
.tab { background: var(--panel2); border: 1px solid #2a3245; border-radius: 99px; padding: .4rem 1rem; font-size: .9rem; transition: all .2s; }
.tab:hover { border-color: var(--accent); }
.tab.active { background: var(--accent); border-color: var(--accent); color: #0b0e14; font-weight: 600; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  #app { flex-direction: column; }
  #sidebar { width: 100%; height: auto; position: sticky; top: 0; flex-direction: row;
    overflow-x: auto; padding: .6rem; gap: .3rem; border-right: 0; border-bottom: 1px solid #202839; z-index: 20; }
  #sidebar .logo { display: none; }
  #sidebar a { white-space: nowrap; padding: .45rem .7rem; }
  
  #main { --main-pad-x: 1rem; --main-pad-top: 1rem; padding: var(--main-pad-top) var(--main-pad-x); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; }
}

/* Divider pushes itself + Settings to the bottom of the sidebar */
.sidebar-divider {
  margin-top: auto;
  height: 2px;
  background: #202839;
  margin-left: .0rem;
  margin-right: .0rem;
  margin-bottom: .4rem;
  flex-shrink: 0;
}

@media (max-width: 860px) {
  .sidebar-divider {
    margin-top: 0;
    margin-left: auto;
    width: 1px;
    height: 22px;
    align-self: center;
    margin-right: .4rem;
    margin-bottom: 0;
  }
}

/* Continue Watching row - horizontal scroll */
.continue-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.continue-scroll {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.25rem 0.25rem 0.5rem;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x mandatory;
}

.continue-scroll::-webkit-scrollbar { display: none; }

.continue-scroll .continue-card {
  flex: 0 0 160px;
  width: 160px;
  cursor: pointer;
  transition: transform 0.2s;
  position: relative;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
}

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

.continue-scroll .card-poster {
  width: 160px;
  height: 240px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel2);
  position: relative;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  flex-shrink: 0;
}

.continue-scroll .card-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.continue-scroll .poster-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  background: var(--panel2);
}

.continue-scroll .card-info {
  padding: 0.4rem 0 0;
  width: 160px;
  height: 41px;
  overflow: hidden;
  flex-shrink: 0;
}

.continue-scroll .card-info .card-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-height: 1.3em;
}

.continue-scroll .card-meta {
  display: flex;
  gap: 0.5rem;
  font-size: 0.72rem;
  color: var(--dim);
  line-height: 1.5;
  height: 1.5em;
  overflow: hidden;
  margin-top: 2px;
}

.continue-scroll .card-meta:empty {
  height: 0;
  margin: 0;
}

/* X button */
.remove-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 1rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
  z-index: 2;
  padding: 0;
  line-height: 1;
}

.continue-scroll .continue-card:hover .remove-btn {
  opacity: 1;
}

.remove-btn:hover {
  background: var(--danger);
  border-color: var(--danger);
  transform: none !important;
}

/* Reset-watched (↺) button on Continue Watching cards — sits opposite the
   remove (×) button so both are reachable on hover without overlapping. */
.continue-scroll .continue-card .continue-reset-btn {
  position: absolute;
  top: 6px;
  left: 6px;
  bottom: auto;
  right: auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  opacity: 0;
  z-index: 2;
}

.continue-scroll .continue-card:hover .continue-reset-btn {
  opacity: 1;
}

.continue-reset-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0e14;
}

/* Specificity fix: the base rule above (3 classes) otherwise beats this
   hover rule's background/border on the actual .continue-reset-btn element,
   leaving the icon a dark glyph on an unchanged near-black circle. */
.continue-scroll .continue-card .continue-reset-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0e14;
}

/* Scroll arrows */
.continue-wrap {
  position: relative;
}

.scroll-arrow {
  position: absolute;
  top: 120px;
  transform: translateY(-5%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(22, 27, 38, 0.9);
  border: 1px solid #2a3245;
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s, color 0.2s, opacity 0.2s;
  /* No transform on hover - only color change */
}

.scroll-arrow:hover {
  background: var(--accent);
  color: #0b0e14;
  border-color: var(--accent);
}

.scroll-arrow.left { left: -8px; }
.scroll-arrow.right { right: -8px; }

.scroll-arrow.hidden {
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 860px) {
  .continue-scroll .continue-card { flex: 0 0 130px; width: 130px; }
  .continue-scroll .card-poster { width: 130px; height: 195px; }
  .continue-scroll .card-info { width: 130px; }
  .scroll-arrow { display: none; }
}

/* ============================== HLS Video Player ============================== */
.video-container {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
}

.video-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.video-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  z-index: 5;
}

.video-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: rgba(0,0,0,0.85);
  z-index: 5;
  color: var(--danger);
  text-align: center;
  padding: 2rem;
}

.video-error button {
  color: var(--text);
}

/* Custom video controls overlay */
 .video-controls {
   position: absolute;
   bottom: 0;
   left: 0;
   right: 0;
   background: linear-gradient(transparent, rgba(0,0,0,0.85));
   padding: 1rem;
   display: flex;
   flex-direction: column;
   gap: 0.5rem;
   opacity: 1;
   transition: opacity 0.3s;
   z-index: 4;
 }

.video-container:hover .video-controls,
.video-controls.visible {
  opacity: 1;
}

.video-progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
}

.video-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.1s linear;
}

.video-controls-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.video-controls-row button {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  padding: 0.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
}

.video-controls-row button:hover {
  color: var(--accent);
}

.video-time {
  color: #fff;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

 .video-title-bar {
   position: absolute;
   top: 0;
   left: 0;
   right: 0;
   background: linear-gradient(rgba(0,0,0,0.85), transparent);
   padding: 1rem;
   display: flex;
   align-items: center;
   gap: 0.75rem;
   opacity: 1;
   transition: opacity 0.3s;
   z-index: 4;
 }
 
  /* Netflix-style: hide controls + cursor when idle */
 .video-container.controls-hidden .video-controls,
 .video-container.controls-hidden .video-title-bar {
   opacity: 0 !important;
   pointer-events: none !important;
 }
 .video-container.controls-hidden {
   cursor: none;
 }

.video-container:hover .video-title-bar,
.video-title-bar.visible {
  opacity: 1;
}

.video-title-bar .v-title {
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: auto;
}

.video-title-bar button {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  border-radius: 8px;
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
}

.video-title-bar button:hover {
  background: rgba(255,255,255,0.2);
}

/* Speed menu */
.speed-menu {
  position: absolute;
  bottom: 60px;
  right: 1rem;
  background: var(--panel);
  border: 1px solid #2a3245;
  border-radius: 10px;
  padding: 0.5rem;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.speed-menu button {
  background: none;
  border: none;
  color: var(--text);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  text-align: left;
  font-size: 0.85rem;
}

.speed-menu button:hover,
.speed-menu button.active {
  background: var(--accent);
  color: #0b0e14;
}

/* Volume slider */
.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 4px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

/* Provider source selector in video player */
.video-source-select {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  border-radius: 8px;
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
}

.video-source-select option {
  background: var(--panel);
  color: var(--text);
}
/* ============================== anime watch page (Miruro-style) ============================== */
.watch-page { display: flex; flex-direction: column; position: relative; }
.watch-banner {
  position: absolute; overflow: hidden; pointer-events: none;
  top: calc(var(--main-pad-top) * -1);
  left: calc(var(--main-pad-x) * -1);
  right: calc(var(--main-pad-x) * -1);
  height: 480px;
  background-size: cover; background-position: center 25%; background-color: var(--panel);
  z-index: 0;
}
.watch-banner-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(13,16,23,.6) 0%, rgba(13,16,23,.15) 28%, rgba(13,16,23,.3) 55%, rgba(13,16,23,.92) 85%, var(--bg) 100%);
}
.watch-topbar { position: relative; z-index: 2; padding-bottom: .8rem; }
.watch-back-btn {
  background: rgba(10,13,20,.55); border-color: rgba(255,255,255,.18); backdrop-filter: blur(4px);
}

.watch-layout {
  display: grid; grid-template-columns: minmax(0,1fr) 340px; gap: 1.5rem;
  position: relative; z-index: 1;
}
.watch-main { display: flex; flex-direction: column; min-width: 0; }
.watch-player-box {
  aspect-ratio: 16/9; width: 100%; background: #000; border-radius: var(--radius);
  overflow: hidden; position: relative; box-shadow: 0 12px 34px rgba(0,0,0,.5);
}
.watch-player-box .p-center { height: 100%; }
.watch-player-box .video-container, .watch-player-box .p-frame { border-radius: 0; }
.watch-player-bar { margin: .8rem 0 1.2rem; border-radius: 12px; background: var(--panel); border: 1px solid #232c3f; border-bottom: 1px solid #232c3f; }
.watch-player-bar.p-bar .p-title.watch-ep-label { max-width: none; }
.watch-src-select { min-width: 160px; }
button.watch-player-placeholder {
  width: 100%; height: 100%; border: 0; border-radius: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .8rem; color: var(--dim); background: var(--panel); cursor: pointer;
  font: inherit; font-size: 1rem;
}
button.watch-player-placeholder:hover { background: var(--panel2); color: var(--text); transform: none; }
button.watch-player-placeholder .drama-play-icon { pointer-events: none; }

.watch-info {
  display: flex; gap: 1.2rem; flex-wrap: wrap; align-items: flex-start; background: var(--panel);
  border: 1px solid #232c3f; border-radius: var(--radius); padding: 1.2rem;
}
.watch-poster {
  position: relative;
  flex: 0 0 120px; width: 120px; aspect-ratio: 2/3; border-radius: 10px;
  background-size: cover; background-position: center; background-color: var(--panel2);
  box-shadow: 0 6px 16px rgba(0,0,0,.4);
}
.watch-info-text { flex: 1; min-width: 200px; }
.watch-info-text h1 { font-size: 1.5rem; margin-bottom: .3rem; line-height: 1.2; }
.watch-meta { color: var(--dim); font-size: .88rem; margin-bottom: .6rem; }

.watch-sidebar {
  background: var(--panel); border: 1px solid #232c3f; border-radius: var(--radius);
  display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 90px);
  position: sticky; top: 1rem; align-self: start;
}
.watch-sidebar-head { padding: 1rem 1rem .8rem; display: flex; flex-direction: column; gap: .6rem; border-bottom: 1px solid #232c3f; flex-shrink: 0; }
.watch-sidebar-head h3 { font-size: 1.1rem; margin: 0; }
.watch-ep-search { width: 100%; }
.watch-ep-list { overflow-y: auto; padding: .5rem; display: flex; flex-direction: column; gap: .25rem; flex: 1; min-height: 120px; }
.watch-ep-item {
  display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border-radius: 10px;
  cursor: pointer; transition: background .2s;
}
.watch-ep-item:hover { background: var(--panel2); }
.watch-ep-item.active {
  background: rgba(108, 140, 255, 0.22);
  border-left: 3px solid var(--accent);
  padding-left: calc(.7rem - 3px);
}
.watch-ep-item.active:hover { background: rgba(108, 140, 255, 0.28); }
.watch-ep-item.active .watch-ep-num,
.watch-ep-item.active .watch-ep-title { color: var(--accent); font-weight: 600; }
.watch-ep-num { color: var(--dim); min-width: 2rem; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.watch-ep-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ep-playing-tag { color: var(--accent); font-size: .78rem; font-weight: 600; flex-shrink: 0; white-space: nowrap; }
.watch-more-btn { margin: .6rem; flex-shrink: 0; }

@media (max-width: 1080px) {
  .watch-layout { grid-template-columns: 1fr; }
  .watch-sidebar { position: static; max-height: 60vh; }
  .watch-banner { height: 380px; }
}
@media (max-width: 860px) {
  .watch-banner { height: 300px; }
  .watch-info { flex-direction: column; align-items: center; text-align: center; padding: 1rem; }
  .watch-poster { flex: 0 0 130px; width: 130px; }
  .watch-player-bar { flex-direction: column; align-items: stretch; }
  .watch-player-bar > div[style*="flex:1"] { display: none; }
}

/* ============================== kisskh-style drama detail ============================== */
.drama-ov {
  padding: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background: rgba(3,5,9,.97);
}

.drama-sheet {
  width: min(1200px, 100%);
  height: 100%;
  overflow-y: auto;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* top bar */
.drama-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .8rem 1.2rem;
  background: var(--panel);
  border-bottom: 1px solid #232c3f;
  flex-shrink: 0;
  gap: 1rem;
}
.drama-topbar-left {
  display: flex;
  align-items: center;
  gap: .8rem;
  min-width: 0;
}
.drama-poster-sm {
  width: 42px;
  height: 60px;
  border-radius: 6px;
  background-size: cover;
  background-position: center;
  background-color: var(--panel2);
  flex-shrink: 0;
}
.drama-title {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40vw;
}
.drama-meta-row {
  display: flex;
  gap: .6rem;
  color: var(--dim);
  font-size: .78rem;
  margin-top: .15rem;
  flex-wrap: wrap;
}
.drama-meta-row span:not(:last-child)::after {
  content: '·';
  margin-left: .6rem;
  color: #3a4255;
}
.drama-status { font-weight: 600; padding: 0 6px; border-radius: 4px; font-size: .72rem; }
.drama-status.ended   { color: var(--ok); background: rgba(62,207,142,.1); }
.drama-status.ongoing { color: var(--accent); background: rgba(108,140,255,.1); }
.drama-topbar-right { flex-shrink: 0; display: flex; align-items: center; gap: .6rem; }
.drama-src-sel { min-width: 140px; font-size: .85rem; }
.drama-reset-btn {
  background: transparent;
  color: var(--dim);
  font-size: .82rem;
  white-space: nowrap;
}
.drama-reset-btn:hover { color: var(--text); border-color: var(--accent); }

/* two-column layout */
.drama-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 0;
  flex: 1;
  min-height: 0;
}

/* LEFT: player + info */
.drama-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid #232c3f;
}

.drama-player-box {
  aspect-ratio: 16/9;
  width: 100%;
  background: #000;
  position: relative;
  flex-shrink: 0;
}
.drama-player-box .video-container { border-radius: 0; }
.drama-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}
.drama-player-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .8rem;
  color: var(--dim);
  background: var(--panel);
}
.drama-play-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent);
  color: #0b0e14;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.drama-info-below {
  padding: 1rem 1.2rem;
  flex: 1;
  overflow-y: auto;
}
.drama-genres {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-bottom: .8rem;
}
.drama-synopsis-text {
  color: #b8bfce;
  font-size: .88rem;
  line-height: 1.6;
  max-width: 80ch;
}

/* RIGHT: episodes sidebar */
.drama-sidebar {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  min-height: 0;
  overflow: hidden;
}
.drama-ep-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .8rem 1rem;
  border-bottom: 1px solid #232c3f;
  flex-shrink: 0;
}
.drama-ep-header h3 {
  font-size: .95rem;
  font-weight: 700;
  margin: 0;
  margin-right: auto;
}
.drama-season-sel { font-size: .82rem; min-width: 110px; }

.drama-ep-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: .4rem;
  padding: .8rem;
  overflow-y: auto;
  flex: 1;
  align-content: start;
}

.drama-ep-btn {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel2);
  border: 1px solid #2a3245;
  border-radius: 6px;
  font-size: .82rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all .15s;
  padding: 0;
}
.drama-ep-btn:hover {
  border-color: var(--accent);
  background: rgba(108,140,255,.12);
}
.drama-ep-btn.watched {
  background: rgba(62,207,142,.07);
  border-color: rgba(62,207,142,.2);
  color: var(--ok);
}
.drama-ep-btn.current {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0e14;
  font-weight: 700;
}

.drama-back-btn {
  background: transparent;
  border: 1px solid #2a3245;
  color: var(--dim);
  border-radius: 8px;
  padding: .4rem .8rem;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  flex-shrink: 0;
}
.drama-back-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.simkl-status { margin-bottom: 1rem; }
.simkl-code-section {
  background: var(--panel2);
  border: 1px solid #2a3245;
  border-radius: 12px;
  margin-top: 1rem;
  overflow: hidden;
}

/* responsive */
@media (max-width: 900px) {
  .drama-layout { grid-template-columns: 1fr; }
  .drama-main { border-right: none; border-bottom: 1px solid #232c3f; }
  .drama-sidebar { max-height: 40vh; }
  .drama-title { max-width: 50vw; }
}
@media (max-width: 600px) {
  .drama-topbar { padding: .6rem .8rem; }
  .drama-poster-sm { display: none; }
  .drama-title { font-size: .95rem; max-width: 45vw; }
  .drama-ep-grid { grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); }
  .drama-reset-btn { padding: .5rem .6rem; font-size: 0; }
  .drama-reset-btn::before { content: '↺'; font-size: .95rem; }
}

/* ============================== PROFILE SCREENS ============================== */
body.profile-mode #main {
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 100vh !important;
}

.profile-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 2rem 1rem;
}

.profile-title {
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 3rem;
  text-align: center;
  color: var(--text);
}

.profile-grid {
  display: flex;
  gap: 2.5rem;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
}

.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  cursor: pointer;
  transition: transform 0.2s ease;
  position: relative;
  width: 130px;
}

.profile-card:hover {
  transform: scale(1.08);
}

.profile-avatar {
  width: 120px;
  height: 120px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  border: 3px solid transparent;
}

.profile-card:hover .profile-avatar {
  box-shadow: 0 0 0 3px var(--accent), 0 8px 30px rgba(0, 0, 0, 0.5);
}

.profile-avatar.add-avatar {
  background: var(--panel2) !important;
  border: 2px dashed #3a4255;
  font-size: 2.8rem;
  color: var(--dim);
}

.profile-name {
  font-size: 0.95rem;
  color: var(--dim);
  font-weight: 500;
  text-align: center;
  transition: color 0.2s;
}

.profile-card:hover .profile-name {
  color: var(--text);
}

.profile-lock {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 1.1rem;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.7));
}

/* ---------- profile create form ---------- */
.profile-form {
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  background: var(--panel);
  border: 1px solid #232c3f;
  border-radius: 16px;
  padding: 2rem;
}

.profile-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.profile-label {
  font-size: 0.8rem;
  color: var(--dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.profile-name-input {
  width: 100%;
}

.avatar-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.avatar-opt {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel2);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
}

.avatar-opt:hover {
  border-color: #3a4255;
  transform: scale(1.05);
}

.avatar-opt.selected {
  border-color: var(--accent);
  background: rgba(108, 140, 255, 0.15);
  transform: scale(1.05);
}

.color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.color-opt {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
}

.color-opt:hover {
  transform: scale(1.2);
}

.color-opt.selected {
  border-color: #fff;
  transform: scale(1.2);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.3);
}

.pass-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text);
}

.pass-section {
  margin-top: 0.4rem;
}

.profile-btn-row {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.profile-create-btn {
  padding: 0.7rem 2rem;
}

/* ---------- PIN input ---------- */
.pin-row {
  display: flex;
  gap: 0.7rem;
  justify-content: center;
  position: relative;
}

/* The real input: invisible, sized to cover the whole box row, so tapping
   anywhere in the row (handled by pinRow's onclick) or tapping the boxes
   themselves focuses it. One real input avoids iOS's OTP-grid keyboard
   quirk that a row of 4 separate maxlength=1 inputs triggers. */
.pin-hidden-input {
  position: absolute;
  opacity: 0;
  height: 64px;
  width: 100%;
  left: 0;
  top: 0;
  font-size: 16px; /* prevents iOS auto-zoom-on-focus */
}

.pin-box {
  width: 56px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  font-weight: 700;
  border-radius: 12px;
  background: var(--panel2);
  border: 2px solid #2a3245;
  color: var(--text);
  transition: border-color 0.2s;
}

.pin-box.filled {
  border-color: var(--accent);
}

.pin-box.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent);
  animation: pin-cursor-blink 1s step-end infinite;
}

@keyframes pin-cursor-blink {
  0%, 100% { border-color: var(--accent); }
  50% { border-color: #2a3245; }
}

.pin-input {
  -webkit-text-security: disc;
  width: 56px;
  height: 64px;
  text-align: center;
  font-size: 1.7rem;
  font-weight: 700;
  border-radius: 12px;
  background: var(--panel2);
  border: 2px solid #2a3245;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  caret-color: var(--accent);
}

.pin-input:focus {
  border-color: var(--accent);
}

.pin-error {
  color: var(--danger);
  text-align: center;
  margin-top: 0.8rem;
  font-size: 0.85rem;
}

.profile-passcode-name {
  text-align: center;
  margin-bottom: 1rem;
  font-size: 1.3rem;
}

.shake {
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

/* ---------- responsive ---------- */
@media (max-width: 600px) {
  .profile-avatar {
    width: 90px;
    height: 90px;
    font-size: 2.5rem;
  }
  .profile-title {
    font-size: 1.6rem;
    margin-bottom: 2rem;
  }
  .profile-grid {
    gap: 1.5rem;
  }
  .profile-card {
    width: 100px;
  }
  .pin-input {
    width: 48px;
    height: 56px;
    font-size: 1.4rem;
  }
  .profile-form {
    padding: 1.2rem;
  }
}
/* ============================== series detail (cineby-style) ============================== */
.sheet.sheet-series {
  width: min(1300px, 100%);
  padding: 0;
  overflow: hidden;
  overflow-y: auto;
}

.sheet-series .close-x.sd-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 5;
  background: rgba(10,13,20,.6);
  backdrop-filter: blur(4px);
}

.sd-hero {
  position: relative;
  width: 100%;
  min-height: 460px;
  background-size: cover;
  background-position: center top;
  background-color: var(--panel2);
  display: flex;
  align-items: flex-end;
}

.sd-hero-gradient {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(0deg, var(--panel) 0%, rgba(22,27,38,.85) 18%, rgba(22,27,38,.15) 55%, rgba(22,27,38,.05) 100%),
    linear-gradient(90deg, rgba(10,13,20,.9) 0%, rgba(10,13,20,.55) 32%, rgba(10,13,20,.1) 65%);
}

.sd-hero-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  gap: 1.6rem;
  padding: 2rem clamp(1.2rem, 3vw, 2.8rem) 2.2rem;
  width: 100%;
}

.sd-poster {
  flex: 0 0 170px;
  width: 170px;
  aspect-ratio: 2/3;
  border-radius: 12px;
  background-size: cover;
  background-position: center;
  background-color: var(--panel2);
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  border: 1px solid rgba(255,255,255,.08);
}

.sd-info {
  flex: 1;
  min-width: 260px;
  max-width: 760px;
}

.sd-title {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 800;
  line-height: 1.15;
  text-shadow: 0 2px 10px rgba(0,0,0,.7);
  margin-bottom: .55rem;
}

.sd-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .9rem;
  color: #d0d6e4;
  font-size: .92rem;
  margin-bottom: .7rem;
}

.sd-rating { color: #ffc857; font-weight: 700; }

.sd-status {
  border-radius: 6px;
  padding: 1px 8px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.sd-status.ongoing { background: rgba(62,207,142,.18); color: var(--ok); }
.sd-status.ended { background: rgba(139,147,167,.18); color: var(--dim); }

.sd-genres { margin-bottom: .8rem; }

.sd-overview {
  color: #dfe3ec;
  font-size: .96rem;
  line-height: 1.55;
  margin-bottom: 1.2rem;
  max-width: 68ch;
  text-shadow: 0 1px 6px rgba(0,0,0,.5);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sd-reset-btn {
  background: transparent;
  color: var(--dim);
}
.sd-reset-btn:hover { color: var(--text); border-color: var(--accent); }

.sd-section-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
}

/* ---- cast row ---- */
.sd-cast {
  padding: 1.4rem clamp(1.2rem, 3vw, 2.8rem) 0;
}
.sd-cast-scroll {
  display: flex;
  gap: 1.1rem;
  overflow-x: auto;
  padding: .9rem .1rem .3rem;
  scrollbar-width: none;
}
.sd-cast-scroll::-webkit-scrollbar { display: none; }
.sd-cast-item {
  flex: 0 0 84px;
  width: 84px;
  text-align: center;
}
.sd-cast-photo {
  width: 72px; height: 72px;
  border-radius: 50%;
  margin: 0 auto .5rem;
  background-size: cover;
  background-position: center top;
  background-color: var(--panel2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
.sd-cast-name {
  font-size: .78rem; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sd-cast-char {
  font-size: .72rem; color: var(--dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---- episodes ---- */
.sd-episodes {
  padding: 1.6rem clamp(1.2rem, 3vw, 2.8rem) 2.2rem;
}
.sd-episodes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.sd-season-select {
  min-width: 220px;
  font-weight: 600;
}

.sd-ep-grid {
  display: flex;
  flex-direction: column;
  gap: .7rem;
}

.sd-ep-card {
  display: flex;
  gap: 1rem;
  background: var(--panel2);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: .6rem;
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
}
.sd-ep-card:hover {
  border-color: var(--accent);
  background: #232c3f;
}
.sd-ep-card.current {
  border-color: var(--accent);
  background: linear-gradient(90deg, rgba(108,140,255,.14), transparent);
}

.sd-ep-thumb {
  position: relative;
  flex: 0 0 200px;
  width: 200px;
  aspect-ratio: 16/9;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  background-color: #10141d;
  overflow: hidden;
}
.sd-ep-thumb-empty {
  background-image: linear-gradient(135deg, #171d2b 0%, #10141d 100%);
}
.sd-ep-noimg {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 700; letter-spacing: .02em; opacity: .35;
}
.sd-ep-play {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; color: #fff;
  background: rgba(5,8,14,.35);
  opacity: 0;
  transition: opacity .2s;
}
.sd-ep-card:hover .sd-ep-play { opacity: 1; }
.sd-ep-duration {
  position: absolute; bottom: 6px; right: 6px;
  background: rgba(5,8,14,.8);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  line-height: 1.3;
}
.sd-ep-watched {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--ok); color: #0b0e14;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 800;
}

.sd-ep-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: .3rem;
  padding: .2rem 0;
}
.sd-ep-title-row {
  display: flex;
  align-items: baseline;
  gap: .6rem;
}
.sd-ep-num {
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.sd-ep-name {
  font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sd-ep-meta {
  color: var(--dim);
  font-size: .8rem;
}
.sd-ep-overview {
  color: #b7bdcc;
  font-size: .85rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 760px) {
  .sd-hero { min-height: 340px; }
  .sd-hero-content { flex-direction: column; align-items: flex-start; padding: 1.2rem; }
  .sd-poster { display: none; }
  .sd-overview { -webkit-line-clamp: 3; }
  .sd-ep-card { flex-direction: column; }
  .sd-ep-thumb { width: 100%; flex: 0 0 auto; }
}