:root {
  --bg: #0a0b10;
  --card: rgba(255, 255, 255, 0.045);
  --card-border: rgba(255, 255, 255, 0.09);
  --text: #eef0f6;
  --muted: #8b90a4;
  --accent: #7c6cff;
  --accent-2: #00d4c7;
  --danger: #ff5f6d;
  --radius: 18px;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

/* Иначе display:flex у .edit-form перебивает атрибут hidden. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  /* системные шрифты — сайт не зависит от внешних CDN и работает в локальной сети */
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
               "Noto Sans", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* мягкое свечение на фоне */
.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}
.glow--a { width: 520px; height: 520px; background: #5b3dff; top: -180px; left: -120px; }
.glow--b { width: 460px; height: 460px; background: #00a89e; bottom: -200px; right: -140px; opacity: 0.25; }

/* ---------- шапка ---------- */
.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px clamp(16px, 4vw, 48px);
  max-width: 1240px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  font-size: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 24px rgba(124, 108, 255, 0.45);
}

.topbar__nav { display: flex; gap: 10px; }

.wrap {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: 8px clamp(16px, 4vw, 48px) 80px;
}

.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 24px 0 40px;
}

/* ---------- кнопки и поля ---------- */
.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  padding: 11px 18px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #5a4bff);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
  box-shadow: 0 10px 26px rgba(90, 75, 255, 0.35);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 14px 32px rgba(90, 75, 255, 0.45); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn--ghost {
  background: var(--card);
  border: 1px solid var(--card-border);
  box-shadow: none;
  color: var(--text);
}
.btn--ghost:hover { background: rgba(255,255,255,.09); box-shadow: none; }

.btn--danger { background: linear-gradient(135deg, #ff5f6d, #d63a52); box-shadow: none; }
.btn--wide { width: 100%; padding: 13px; }

.input {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: rgba(255,255,255,.04);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 11px 13px;
  outline: none;
  transition: border-color .15s ease, background .15s ease;
}
.input:focus { border-color: var(--accent); background: rgba(255,255,255,.07); }
.input::placeholder { color: #5f6478; }
textarea.input { resize: vertical; }

.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 14px; margin: 0; }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(124, 108, 255, .18);
  color: #b9b0ff;
  border: 1px solid rgba(124, 108, 255, .3);
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: clamp(18px, 3vw, 28px);
  backdrop-filter: blur(14px);
}
.card h2 { margin: 0 0 18px; font-size: 19px; letter-spacing: -.01em; }

/* ---------- плеер ---------- */
.stage { margin-bottom: 44px; }

.player {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr);
  gap: 26px;
  background: linear-gradient(160deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.player__shell {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 16 / 9;
}
.player__shell video { width: 100%; height: 100%; display: block; object-fit: contain; background: #000; }

.player__meta { display: flex; flex-direction: column; gap: 12px; padding: 8px 6px 6px; min-width: 0; }
.player__row { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.player__meta h1 { margin: 0; font-size: clamp(21px, 2.4vw, 28px); line-height: 1.2; letter-spacing: -.02em; }
.player__desc { margin: 0; color: var(--muted); line-height: 1.6; font-size: 15px; }
.player__actions { margin-top: auto; display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- вкладки сезонов ---------- */
.catalog__head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.catalog__head h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.catalog__head p { margin: 0; font-size: 14px; }

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px;
  margin-bottom: 24px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
  background: transparent;
  padding: 10px 18px;
  border-radius: 10px;
  transition: color .15s ease, background .15s ease;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #5a4bff);
  box-shadow: 0 8px 22px rgba(90,75,255,.35);
}
.tab__count { opacity: .7; font-weight: 500; margin-left: 6px; }

/* ---------- сетка серий ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
}

.ep-card {
  cursor: pointer;
  border: 1px solid var(--card-border);
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 0;
  font: inherit;
  color: inherit;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.ep-card:hover { transform: translateY(-4px); border-color: rgba(124,108,255,.5); box-shadow: var(--shadow); }
.ep-card.is-playing { border-color: var(--accent-2); }

.ep-card__thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(140deg, #23264a, #131522);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.ep-card__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ep-card__num { font-size: 30px; font-weight: 800; color: rgba(255,255,255,.22); letter-spacing: -.03em; }

.ep-card__play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(8, 9, 16, .5);
  opacity: 0;
  transition: opacity .18s ease;
}
.ep-card:hover .ep-card__play,
.ep-card.is-playing .ep-card__play { opacity: 1; }
.ep-card__play span {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 17px;
  padding-left: 3px;
  box-shadow: 0 10px 26px rgba(0,0,0,.5);
}

.ep-card__time {
  position: absolute;
  right: 8px; bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(0,0,0,.7);
}

.ep-card__seen {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: rgba(255,255,255,.15);
}
.ep-card__seen i { display: block; height: 100%; background: var(--accent-2); }

.ep-card__body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; }
.ep-card__label { font-size: 11px; font-weight: 800; letter-spacing: .08em; color: var(--accent-2); text-transform: uppercase; }
.ep-card__title { font-weight: 700; font-size: 15px; line-height: 1.35; }
.ep-card__desc {
  font-size: 13px; color: var(--muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}

/* ---------- пустая страница / логин ---------- */
.empty { text-align: center; padding: 90px 20px; }
.empty__icon { font-size: 54px; margin-bottom: 12px; }
.empty h1 { margin: 0 0 8px; letter-spacing: -.02em; }
.empty p { margin: 0 0 24px; }

.login { display: grid; place-items: center; padding: 70px 0; }
.login__card { width: min(400px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login__card h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.login__card p { margin: -6px 0 4px; font-size: 14px; }

/* ---------- админка ---------- */
.admin { display: flex; flex-direction: column; gap: 22px; }
.form { display: flex; flex-direction: column; gap: 16px; align-items: flex-start; }
.form > .btn, .form > .input, .form > .field, .form > .drop,
.form > .form__grid, .form > .progress, .form > .status { align-self: stretch; }
.form__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: var(--muted); font-weight: 600; }
.field--wide { grid-column: 1 / -1; }

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 34px 20px;
  border: 1.5px dashed rgba(255,255,255,.18);
  border-radius: 16px;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s ease, background .15s ease;
}
.drop:hover, .drop.is-over { border-color: var(--accent); background: rgba(124,108,255,.08); }
.drop__icon { font-size: 26px; }
.drop__text { font-weight: 700; font-size: 15px; word-break: break-word; }
.drop .muted { font-size: 13px; }

.progress { height: 8px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; }
.progress__bar { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .2s ease; }

.status { margin: 0; font-size: 14px; min-height: 20px; }
.status.is-ok { color: var(--accent-2); }
.status.is-error { color: var(--danger); }

.ep-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.ep-item {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: rgba(255,255,255,.03);
}
.ep-item__poster {
  aspect-ratio: 16/9;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(140deg, #23264a, #131522);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  color: rgba(255,255,255,.4);
}
.ep-item__poster img { width: 100%; height: 100%; object-fit: cover; }
.ep-item__body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ep-item__title { display: flex; align-items: center; gap: 10px; font-weight: 700; flex-wrap: wrap; }
.ep-item__sub { font-size: 13px; }
.ep-item__actions { display: flex; flex-direction: column; gap: 8px; }
.edit-form { margin-top: 10px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }

@media (max-width: 900px) {
  .player { grid-template-columns: 1fr; }
  .ep-item { grid-template-columns: 96px minmax(0, 1fr); }
  .ep-item__actions { grid-column: 1 / -1; flex-direction: row; }
}

@media (max-width: 560px) {
  .form__grid { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
  .brand__text { font-size: 16px; }
}
