:root {
  --bg: #07090d;
  --surface: #10141b;
  --surface-2: #171d26;
  --surface-3: #202734;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f5f7fb;
  --muted: #a9b2c0;
  --muted-2: #778294;
  --accent: #1db4ff;
  --accent-2: #ff4d6d;
  --focus: rgba(29, 180, 255, 0.35);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(29, 180, 255, 0.12), transparent 30rem),
    linear-gradient(180deg, #0a0d12 0%, var(--bg) 42rem);
  color: var(--text);
}

body.is-locked {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.page {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 430px);
  gap: 20px;
  align-items: end;
  margin-bottom: 22px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: linear-gradient(145deg, #172333, #0e1218);
  color: var(--accent);
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 6vw, 4.2rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.search-panel {
  position: relative;
}

.search-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.search-input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 20, 27, 0.86);
  color: var(--text);
  outline: 0;
  padding: 0 15px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.search-input::placeholder {
  color: var(--muted-2);
}

.search-input:focus {
  border-color: rgba(29, 180, 255, 0.7);
  box-shadow: 0 0 0 4px var(--focus);
}

.controls {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 29, 38, 0.86);
  color: var(--muted);
  cursor: pointer;
  padding: 0 13px;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease, transform 150ms ease;
}

.tab-button:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.tab-button:focus-visible,
.load-more:focus-visible,
.video-card:focus-visible,
.icon-button:focus-visible,
.rutube-link:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 4px var(--focus);
}

.tab-button.is-active {
  border-color: rgba(29, 180, 255, 0.65);
  background: rgba(29, 180, 255, 0.14);
  color: var(--text);
}

.result-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.92rem;
}

.grid-wrap {
  min-height: 420px;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.video-card {
  display: flex;
  min-width: 0;
  height: 100%;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  text-align: left;
  transition: border-color 150ms ease, transform 150ms ease, background 150ms ease;
  --chip: var(--accent);
  --chip-border: rgba(29, 180, 255, 0.24);
  --chip-border-strong: rgba(29, 180, 255, 0.5);
  --chip-bg: rgba(29, 180, 255, 0.1);
  --chip-text: #9adcff;
}

.video-card:hover {
  border-color: var(--chip-border-strong);
  background: #121923;
  transform: translateY(-2px);
}

.video-card[data-category="авто"] {
  --chip: #ffb547;
  --chip-border: rgba(255, 181, 71, 0.28);
  --chip-border-strong: rgba(255, 181, 71, 0.52);
  --chip-bg: rgba(255, 181, 71, 0.12);
  --chip-text: #ffd493;
}

.video-card[data-category="игры"] {
  --chip: #69d98f;
  --chip-border: rgba(105, 217, 143, 0.28);
  --chip-border-strong: rgba(105, 217, 143, 0.52);
  --chip-bg: rgba(105, 217, 143, 0.12);
  --chip-text: #aaf0bf;
}

.video-card[data-category="музыка"] {
  --chip: #ff6f9f;
  --chip-border: rgba(255, 111, 159, 0.28);
  --chip-border-strong: rgba(255, 111, 159, 0.52);
  --chip-bg: rgba(255, 111, 159, 0.12);
  --chip-text: #ffbad0;
}

.video-card[data-category="спорт"] {
  --chip: #5bc8ff;
  --chip-border: rgba(91, 200, 255, 0.28);
  --chip-border-strong: rgba(91, 200, 255, 0.52);
  --chip-bg: rgba(91, 200, 255, 0.12);
  --chip-text: #b5e8ff;
}

.thumb-shell {
  position: relative;
  aspect-ratio: 9 / 16;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.08), transparent 34%),
    #111823;
  overflow: hidden;
}

.thumb-shell::before {
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 0%, rgba(255, 255, 255, 0.08) 45%, transparent 70%);
  content: "";
  transform: translateX(-100%);
  animation: loading-glint 1.45s infinite;
}

.thumb-shell.is-loaded::before {
  display: none;
}

.thumb-shell img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 220ms ease;
}

.thumb-shell.is-loaded img {
  opacity: 1;
}

.play-badge {
  position: absolute;
  right: 9px;
  bottom: 9px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: rgba(7, 9, 13, 0.74);
  backdrop-filter: blur(10px);
}

.play-badge::before {
  width: 0;
  height: 0;
  margin-left: 3px;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 11px solid var(--text);
  content: "";
}

.duration {
  position: absolute;
  left: 8px;
  bottom: 9px;
  border-radius: 6px;
  background: rgba(7, 9, 13, 0.78);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 800;
  padding: 4px 6px;
}

.card-body {
  display: flex;
  min-height: 118px;
  flex: 1;
  flex-direction: column;
  gap: 9px;
  padding: 12px;
}

.tag-row {
  display: flex;
  min-width: 0;
  gap: 7px;
  align-items: center;
  justify-content: space-between;
}

.category-pill {
  max-width: 100%;
  border: 1px solid var(--chip-border);
  border-radius: 7px;
  background: var(--chip-bg);
  color: var(--chip-text);
  font-size: 0.72rem;
  font-weight: 800;
  overflow: hidden;
  padding: 4px 7px;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.card-title {
  display: -webkit-box;
  min-height: 3.8em;
  overflow: hidden;
  color: var(--text);
  font-size: 0.96rem;
  font-weight: 760;
  line-height: 1.28;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.channel {
  margin-top: auto;
  color: var(--muted);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  width: min(460px, 100%);
  margin: 54px auto 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 20, 27, 0.74);
  padding: 26px;
  text-align: center;
}

.empty-state h2 {
  margin-bottom: 8px;
  font-size: 1.3rem;
}

.empty-state p {
  color: var(--muted);
}

.load-row {
  display: flex;
  justify-content: center;
  padding-top: 24px;
}

.load-more {
  min-height: 44px;
  border: 1px solid rgba(29, 180, 255, 0.55);
  border-radius: 8px;
  background: rgba(29, 180, 255, 0.14);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  padding: 0 18px;
}

.load-more:hover {
  background: rgba(29, 180, 255, 0.22);
}

.modal {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal.is-open {
  display: flex;
}

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

.modal-dialog {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  max-height: min(92vh, 860px);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #0d1118;
  box-shadow: var(--shadow);
  overflow: auto;
}

.modal-head {
  display: flex;
  gap: 16px;
  align-items: start;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

.modal-meta {
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.modal-head h2 {
  font-size: clamp(1.08rem, 4vw, 1.45rem);
  line-height: 1.22;
  overflow-wrap: anywhere;
}

.icon-button {
  position: relative;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  cursor: pointer;
}

.icon-button span,
.icon-button span::after {
  position: absolute;
  top: 18px;
  left: 10px;
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
  content: "";
  transform: rotate(45deg);
}

.icon-button span::after {
  top: 0;
  left: 0;
  transform: rotate(90deg);
}

.player-shell {
  aspect-ratio: 16 / 9;
  background: #000;
}

.player-shell iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.rutube-link {
  display: inline-flex;
  margin: 14px 16px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 800;
  padding: 10px 13px;
  text-decoration: none;
}

.rutube-link:hover {
  border-color: rgba(255, 255, 255, 0.24);
}

@keyframes loading-glint {
  to {
    transform: translateX(100%);
  }
}

@media (min-width: 900px) {
  .video-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
  }
}

@media (max-width: 720px) {
  .page {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .controls {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .result-count {
    font-size: 0.85rem;
  }

  .card-body {
    min-height: 126px;
    padding: 10px;
  }

  .card-title {
    font-size: 0.88rem;
  }

  .channel {
    font-size: 0.78rem;
  }

  .modal {
    padding: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
