:root {
  --bg: #262626;
  --bg-header: #232323;
  --bg-intro: #1b1b1b;
  --bg-tag: #333;
  --black: #000;
  --text: #fff;
  --text-muted: #d4d4d4;
  --accent: #f26b1d;
  --header-h: 118px;
  --footer-h: 73px;
  --gutter: 24px;
}

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

html,
body {
  margin: 0;
}

body {
  min-height: 100vh;
  padding-bottom: var(--footer-h);
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
}

body.is-locked,
body.is-player-open {
  overflow: hidden;
}

/* Атрибут hidden должен побеждать display из классов (.loader и т.п.) */
[hidden] {
  display: none !important;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Header */

.header {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--header-h);
  padding: 0 var(--gutter);
  background: var(--bg-header);
}

.logo svg {
  display: block;
  width: 142px;
  height: auto;
}

.burger {
  position: absolute;
  top: 50%;
  right: 24px;
  z-index: 50;
  width: 34px;
  height: 34px;
  margin-top: -17px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.burger span {
  position: absolute;
  left: 2px;
  width: 30px;
  height: 3px;
  border-radius: 2px;
  background: #fff;
  transition: transform .25s ease, opacity .2s ease, top .25s ease;
}

.burger span:nth-child(1) { top: 7px; }
.burger span:nth-child(2) { top: 15px; }
.burger span:nth-child(3) { top: 23px; }

.burger.is-active span:nth-child(1) { top: 15px; transform: rotate(45deg); }
.burger.is-active span:nth-child(2) { opacity: 0; }
.burger.is-active span:nth-child(3) { top: 15px; transform: rotate(-45deg); }

/* Menu: desktop — side panel on the right */

.menu {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  width: 402px;
  max-width: 100%;
  padding-top: 80px;
  background: var(--black);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform .3s ease, visibility .3s;
}

.menu.is-open {
  transform: none;
  visibility: visible;
}

.menu__list {
  text-align: center;
}

.menu__list a {
  display: inline-block;
  padding: 18px 24px;
  font-size: 36px;
  font-weight: 700;
  line-height: 1.2;
  transition: color .2s;
}

.menu__list a:hover,
.menu__list a:focus-visible {
  color: var(--accent);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 35;
}

/* Intro */

.intro {
  padding: 14px var(--gutter) 16px;
  background: var(--bg-intro);
  text-align: center;
  font-size: 18px;
}

.intro p {
  margin: 0 auto;
  max-width: 720px;
}

.intro__text {
  color: var(--text-muted);
}

.intro__accent {
  margin-top: 8px !important;
  color: var(--accent);
  font-style: italic;
}

/* Content */

.content {
  padding: 28px var(--gutter) 24px;
}

.tags {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
}

.tag {
  display: block;
  padding: 1px 8px;
  border-radius: 4px;
  background: var(--bg-tag);
  font-size: 15px;
  white-space: nowrap;
  transition: background .2s;
}

.tag::before {
  content: "# ";
  color: var(--accent);
}

.tag:hover {
  background: #444;
}

.tag.is-active {
  background: var(--accent);
}

.tag.is-active::before {
  color: #fff;
}

.reels {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px 33px;
}

.reel {
  display: block;
  overflow: hidden;
  aspect-ratio: 220 / 391;
  border-radius: 16px;
  background: #333;
}

.reel__video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  transition: transform .3s ease;
}

.reel:hover .reel__video {
  transform: scale(1.03);
}

/* Feed states */

.feed-msg {
  margin: 24px 0;
  color: var(--text-muted);
  text-align: center;
}

.feed-retry {
  margin-left: 8px;
  padding: 4px 12px;
  border: 0;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.loader {
  display: flex;
  justify-content: center;
  padding: 24px 0;
}

.loader__spinner,
.player__spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, .2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.feed-sentinel {
  height: 1px;
}

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

/* Subscribe bar */

.subscribe {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  height: var(--footer-h);
  padding-top: 7px;
  background: var(--black);
  text-align: center;
}

.subscribe__title {
  margin: 0 0 6px;
  font-size: 16px;
}

.socials {
  display: flex;
  justify-content: center;
  gap: 16px;
}

.social {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--accent);
  transition: filter .2s;
}

.social:hover {
  filter: brightness(1.15);
}

.social svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}

/* Player */

.player {
  position: fixed;
  inset: 0;
  z-index: 100;
  overscroll-behavior: contain;
}

.player__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .92);
}

.player__stage {
  position: absolute;
  top: 50%;
  left: 50%;
  height: min(92vh, 860px);
  aspect-ratio: 9 / 16;
  max-width: calc(100vw - 160px);
  transform: translate(-50%, -50%);
}

.player__frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100%;
  border-radius: 16px;
  background: #000;
}

.player__video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  cursor: pointer;
}

/* Play icon when paused */
.player__state {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .5) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M8 5v14l11-7z'/%3E%3C/svg%3E") 55% 50% / 36px no-repeat;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.player__frame.is-paused .player__state {
  opacity: 1;
}

.player__spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -18px 0 0 -18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.player__frame.is-loading .player__spinner {
  opacity: 1;
}

.player__frame.is-loading .player__state {
  opacity: 0;
}

.player__info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 48px 16px 20px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .75));
  pointer-events: none;
}

.player__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
}

.player__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.player__tags li {
  padding: 1px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .15);
  font-size: 13px;
}

.player__tags li::before {
  content: "# ";
  color: var(--accent);
}

.player__progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, .2);
  pointer-events: none;
}

.player__progress span {
  display: block;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
}

.player__nav,
.player__actions {
  position: absolute;
  left: calc(100% + 16px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.player__nav {
  top: 50%;
  transform: translateY(-50%);
}

.player__actions {
  bottom: 0;
}

.player__btn,
.player__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  cursor: pointer;
  transition: background .2s, opacity .2s;
}

.player__btn:hover:not(:disabled),
.player__close:hover {
  background: var(--accent);
}

.player__btn:disabled {
  opacity: .3;
  cursor: default;
}

.player__btn svg,
.player__close svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.player__btn .icon-muted,
.player__btn.is-muted .icon-sound {
  display: none;
}

.player__btn.is-muted .icon-muted {
  display: block;
}

.player__close {
  position: absolute;
  top: 24px;
  right: 24px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--footer-h) + 24px);
  z-index: 110;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 8px;
  background: #fff;
  color: #1a1a1a;
  font-size: 14px;
  word-break: break-all;
  transform: translateX(-50%);
}

/* Tablet */

@media (max-width: 1100px) {
  .reels {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px 24px;
  }
}

@media (max-width: 860px) {
  .reels {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
}

/* Mobile */

@media (max-width: 600px) {
  :root {
    --header-h: 97px;
    --gutter: 16px;
  }

  .logo svg {
    width: 100px;
  }

  .burger {
    right: 14px;
  }

  /* Menu: mobile — drops down under the header */
  .menu {
    top: var(--header-h);
    bottom: auto;
    left: 0;
    width: auto;
    padding: 56px 0 50px;
    transform: translateY(-12px);
    opacity: 0;
    transition: transform .25s ease, opacity .25s ease, visibility .25s;
  }

  .menu.is-open {
    transform: none;
    opacity: 1;
  }

  .menu__list a {
    padding: 12px 24px;
    font-size: 28px;
  }

  .intro {
    padding: 8px var(--gutter) 12px;
    text-align: left;
    font-size: 15px;
  }

  .intro__accent {
    margin-top: 6px !important;
  }

  .content {
    padding-top: 28px;
  }

  .tags {
    overflow-x: auto;
    margin: 0 calc(var(--gutter) * -1) 28px;
    padding: 0 var(--gutter);
    scrollbar-width: none;
  }

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

  .tag {
    padding: 2px 8px;
  }

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

  /* Player: mobile — full screen, swipe to navigate */
  .player__stage {
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    aspect-ratio: auto;
    transform: none;
  }

  .player__frame {
    border-radius: 0;
  }

  .player__nav {
    display: none;
  }

  .player__actions {
    left: auto;
    right: 12px;
    bottom: calc(110px + env(safe-area-inset-bottom, 0px));
  }

  .player__info {
    padding: 48px 76px calc(24px + env(safe-area-inset-bottom, 0px)) 16px;
  }

  .player__close {
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: 12px;
    background: rgba(0, 0, 0, .4);
  }
}
