:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-2: #1c1c1c;
  --surface-3: #242424;
  --border: #282828;
  --border-2: #353535;
  --accent: #f5c518;
  --accent-dim: rgba(245, 197, 24, .12);
  --text: #fff;
  --muted: #a8a8a8;
  --dim: #555;
  --tg: #229ed9;
}

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

html,
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

body {
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
}

a {
  color: inherit;
}

img {
  display: block;
}

.hidden {
  display: none !important;
}

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 66px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  background: rgba(10, 10, 10, .96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}


.logo {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0;
  text-decoration: none;
  user-select: none;
}

.logo span {
  color: var(--text);
}

.searchWrap {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.search {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}

.search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.search::placeholder {
  color: var(--dim);
}

.searchResults {
  position: absolute;
  top: 48px;
  left: 0;
  z-index: 200;
  width: 100%;
  max-height: 400px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--border-2);
  border-radius: 12px;
  background: rgba(16, 16, 16, .98);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.result {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 8px;
  text-align: left;
  transition: background .14s;
}

.result:hover {
  background: var(--surface-3);
}

.result img {
  width: 38px;
  height: 54px;
  object-fit: cover;
  border-radius: 5px;
  flex: none;
}

.resultTitle {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resultEmpty,
.empty {
  grid-column: 1 / -1;
  padding: 60px 20px;
  color: var(--dim);
  font-size: 15px;
  text-align: center;
}

.episodeEmpty {
  padding: 20px;
  font-size: 13px;
}

.page,
.watch {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 32px 4% 80px;
}

.sectionHead {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.sectionHead::before {
  content: "";
  display: block;
  width: 4px;
  height: 22px;
  flex: none;
  border-radius: 2px;
  background: var(--accent);
}

.sectionHead h2 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0;
}

.historyHead {
  justify-content: flex-start;
}

.historyHead > div {
  display: flex;
  align-items: center;
  gap: 12px;
}

.historyActions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.clearHistoryBtn,
.viewAllBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border: 1px solid var(--border-2);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  transition: background .15s, border-color .15s, color .15s;
}

.clearHistoryBtn:hover {
  border-color: #c94b4b;
  background: #2a1717;
  color: #fff;
}

.viewAllBtn:hover {
  border-color: var(--accent);
  background: var(--surface-3);
  color: var(--text);
}

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

.historyGrid {
  margin-bottom: 32px;
}

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

.poster {
  position: relative;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  transition: transform .22s, box-shadow .22s, border-color .22s;
}

.card:hover .poster,
.card:focus-visible .poster {
  transform: scale(1.04);
  border-color: var(--accent);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .75);
}

.poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.poster-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(0deg, rgba(0, 0, 0, .7), transparent 45%);
}

.newBadge,
.releaseMeta,
.historyMeta {
  position: absolute;
  border-radius: 4px;
  white-space: nowrap;
}

.newBadge {
  top: 8px;
  left: 8px;
  padding: 3px 7px;
  background: var(--accent);
  color: #000;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0;
}

.releaseMeta,
.historyMeta {
  bottom: 8px;
  left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid rgba(255, 255, 255, .15);
  background: rgba(0, 0, 0, .7);
  color: rgba(255, 255, 255, .92);
  font-size: 10px;
  font-weight: 800;
}

.releaseMeta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--accent);
}

.historyDelete {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 7px;
  background: rgba(0, 0, 0, .72);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity .15s, transform .15s, background .15s, border-color .15s;
}

.historyCard:hover .historyDelete,
.historyDelete:focus-visible {
  opacity: 1;
  transform: translateY(0);
}

.historyDelete:hover {
  border-color: #f05a5a;
  background: #c92f2f;
}

.title {
  margin-top: 8px;
  padding: 0 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color .15s;
}

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

.watch {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.watchHead {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.miniPoster {
  width: 88px;
  height: 124px;
  overflow: hidden;
  flex: none;
  border: 1px solid var(--border-2);
  border-radius: 10px;
  background: var(--surface-2);
}

.miniPoster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.titleBlock h1 {
  margin-bottom: 12px;
  overflow-wrap: anywhere;
  font-size: clamp(20px, 3vw, 40px);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.05;
}

.countLine {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.countLine b {
  color: var(--text);
}

.countLine span {
  color: var(--dim);
  font-size: 16px;
  line-height: 1;
}

.watchGrid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: start;
}

.videoColumn {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.videoFrame {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #000;
}

.videoFrame iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  background: #000;
}

.placeholder {
  aspect-ratio: 16 / 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--surface);
  color: var(--dim);
  font-size: 13px;
  text-align: center;
}

.placeholder::before {
  content: "\25B6";
  color: var(--accent);
  font-size: 44px;
  opacity: .35;
}

.videoControls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.now {
  grid-column: 2;
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.epNavBtn {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  transition: background .15s, color .15s, border-color .15s;
}

.epNavBtn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface-3);
  color: var(--text);
}

.epNavBtn:disabled {
  cursor: not-allowed;
  opacity: .3;
}

#prevBtn {
  grid-column: 1;
  justify-self: start;
}

#nextBtn {
  grid-column: 3;
  justify-self: end;
}

.episodesPanel {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 98px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.epHead {
  flex: none;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.epHead strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.seasonNav {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 32px;
  align-items: center;
  flex: none;
  border-bottom: 1px solid var(--border);
}

.seasons {
  display: flex;
  gap: 5px;
  overflow: hidden;
  padding: 8px;
  scroll-behavior: smooth;
}

.season {
  flex: 0 0 auto;
  padding: 5px 10px;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  transition: border-color .15s, color .15s, background .15s;
}

.season:hover {
  border-color: var(--accent);
  color: var(--text);
}

.season.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #000;
  font-weight: 900;
}

.navArrow {
  width: 28px;
  height: 28px;
  margin: 0 2px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 15px;
  transition: border-color .15s, color .15s;
}

.navArrow:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.navArrow:disabled {
  cursor: not-allowed;
  opacity: .25;
}

.episodeNav {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.episodeNav #episodePrev,
.episodeNav #episodeNext {
  flex: none;
  width: 100%;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0;
  transition: background .14s, color .14s;
}

.episodeNav #episodeNext {
  border-top: 1px solid var(--border);
  border-bottom: 0;
}

.episodeNav #episodePrev::before {
  content: "^";
  font-size: 15px;
}

.episodeNav #episodeNext::before {
  content: "v";
  font-size: 15px;
}

.episodeNav #episodePrev:hover:not(:disabled),
.episodeNav #episodeNext:hover:not(:disabled) {
  background: var(--surface-3);
  color: var(--accent);
}

.episodeNav #episodePrev:disabled,
.episodeNav #episodeNext:disabled {
  cursor: not-allowed;
  opacity: .3;
}

.episodes {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  align-content: start;
  overflow-y: auto;
  padding: 10px;
  scrollbar-color: var(--border-2) transparent;
  scrollbar-width: thin;
}

.ep {
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  transition: border-color .15s, color .15s, background .15s, box-shadow .15s;
}

.ep:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--text);
}

.ep.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 0 1px var(--accent) inset;
  color: var(--accent);
}

.epNo {
  font-size: 15px;
  font-weight: 900;
}

.relatedMovies {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  scrollbar-color: var(--border-2) transparent;
  scrollbar-width: thin;
}

.episodeNav:has(.relatedMovies) #episodePrev,
.episodeNav:has(.relatedMovies) #episodeNext {
  display: none !important;
}

.relatedMovie {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  text-align: left;
  transition: border-color .15s, background .15s;
}

.relatedMovie:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.relatedMovie img {
  width: 50px;
  height: 70px;
  flex: none;
  object-fit: cover;
}

.relatedInfo {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 4px;
}

.relatedTitle {
  overflow: hidden;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.relatedDuration {
  color: var(--muted);
  font-size: 11px;
}



#anipastaLoader,
#anipastaTelegramPopup,
#anipastaAbout {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .22s ease, visibility .22s ease;
}

#anipastaLoader {
  z-index: 99999;
  background: rgba(10, 10, 10, .82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#anipastaTelegramPopup {
  z-index: 100001;
  background: rgba(0, 0, 0, .58);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#anipastaAbout {
  z-index: 100002;
  background: rgba(0, 0, 0, .62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#anipastaLoader.show,
#anipastaTelegramPopup.show,
#anipastaAbout.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.loaderBox {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.loaderRing {
  width: 64px;
  height: 64px;
  border: 3px solid rgba(255, 255, 255, .09);
  border-top-color: var(--accent);
  border-right-color: rgba(245, 197, 24, .35);
  border-radius: 50%;
  animation: aniSpin .72s linear infinite;
  box-shadow: 0 0 35px rgba(245, 197, 24, .12);
}

.loaderText {
  color: #aaa;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

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

.anipastaTgBox {
  position: relative;
  width: min(500px, calc(100vw - 32px));
  padding: 40px 28px 34px;
  border: 1px solid #343434;
  border-radius: 24px;
  background: #141414;
  box-shadow: 0 30px 100px rgba(0, 0, 0, .75);
  text-align: center;
  transform: translateY(8px) scale(.98);
  transition: transform .22s ease;
}

#anipastaTelegramPopup.show .anipastaTgBox {
  transform: translateY(0) scale(1);
}

.anipastaTgClose {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid #303030;
  border-radius: 50%;
  background: #202020;
  color: #aaa;
  font-size: 24px;
  line-height: 1;
}

.anipastaTgClose:hover {
  border-color: #555;
  background: #292929;
  color: #fff;
}

.anipastaTgIcon {
  width: 68px;
  height: 68px;
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(34, 158, 217, .15);
  color: #29a9e8;
}

.anipastaTgIcon svg {
  width: 39px;
  height: 39px;
  fill: currentColor;
}

.anipastaTgTitle {
  margin-bottom: 12px;
  font-size: 25px;
  font-weight: 900;
  line-height: 1.2;
}

.anipastaTgText {
  max-width: 390px;
  margin: 0 auto;
  color: #aaa;
  font-size: 16px;
  line-height: 1.55;
}

.anipastaTgJoin {
  min-width: 174px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 26px;
  padding: 13px 24px;
  border-radius: 11px;
  background: var(--tg);
  color: #fff;
  font-size: 17px;
  font-weight: 900;
  text-decoration: none;
  transition: transform .15s, background .15s;
}

.anipastaTgJoin:hover {
  background: #1c91c8;
  transform: translateY(-1px);
}

.anipastaAboutBox {
  width: min(760px, 100%);
  padding: 32px;
  border: 1px solid #282828;
  border-radius: 18px;
  background: #141414;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .6);
  text-align: center;
}

.anipastaAboutLogo {
  color: var(--accent);
  font-size: 28px;
  font-weight: 900;
}

.anipastaAboutLogo span {
  color: #fff;
}

.anipastaAboutBox h2 {
  margin: 18px 0 8px;
  font-size: clamp(24px, 5vw, 38px);
}

.anipastaAboutBox p {
  margin: 0;
  color: #aaa;
  line-height: 1.7;
}

.anipastaAboutActions {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.anipastaAboutActions a,
.anipastaAboutActions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid #353535;
  border-radius: 8px;
  background: #1c1c1c;
  color: #aaa;
  font-weight: 800;
  text-decoration: none;
}

.anipastaAboutActions a:hover,
.anipastaAboutActions button:hover {
  border-color: var(--accent);
  color: #fff;
}

@media (max-width: 1100px) {
  .grid,
  .historyGrid {
    grid-template-columns: repeat(5, 1fr);
  }

  .watchGrid {
    grid-template-columns: minmax(0, 1fr) 310px;
  }
}

@media (max-width: 800px) {
  .header {
    height: 58px;
    padding: 0 16px;
  }

  .logo {
    font-size: 17px;
  }

  .grid,
  .historyGrid {
    grid-template-columns: repeat(4, 1fr);
  }

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

  .episodesPanel {
    position: static;
    max-height: none;
  }

  .watchHead {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 14px;
    padding: 16px;
  }

  .miniPoster {
    width: 72px;
    height: 100px;
  }
}

@media (max-width: 540px) {
  .header {
    height: 54px;
    padding: 0 12px;
  }

  .logo {
    font-size: 15px;
  }

  .page,
  .watch {
    padding: 20px 12px 60px;
  }

  .grid,
  .historyGrid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .watchHead {
    grid-template-columns: 62px minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
  }

  .miniPoster {
    width: 62px;
    height: 88px;
  }

  .titleBlock h1 {
    margin-bottom: 8px;
    font-size: 18px;
  }

  .videoControls {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .now {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  #prevBtn {
    grid-column: 1;
    grid-row: 2;
    justify-self: stretch;
  }

  #nextBtn {
    grid-column: 2;
    grid-row: 2;
    justify-self: stretch;
  }

  .epNavBtn {
    width: 100%;
    text-align: center;
  }

  .episodes {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }

  .ep {
    min-height: 46px;
  }

  .epNo {
    font-size: 13px;
  }

  .season {
    padding: 4px 8px;
    font-size: 10px;
  }

  .alphaFilter {
    justify-content: flex-start;
    margin-top: 20px;
    padding: 8px;
  }

  .alphaBtn {
    min-width: 29px;
    height: 29px;
    padding: 0 7px;
  }

  .anipastaTgBox {
    padding: 34px 20px 28px;
  }

  .anipastaTgTitle {
    font-size: 21px;
  }

  .anipastaTgText {
    font-size: 14px;
  }

  .anipastaTgJoin {
    font-size: 15px;
  }
}
