/* live.proalkash.ru — frontend styles.
   Vanilla CSS, no external assets, no web fonts. Strict minimal layout.
   Dark theme is the default; light theme is opt-in via <html data-theme="light">. */

:root {
  color-scheme: dark;

  --bg: #0b0c0e;
  --bg-elev: #111216;
  --surface: #14151a;
  --surface-2: #1c1d23;
  --text: #ededf0;
  --text-dim: #9d9fa6;
  --text-faint: #6a6c74;
  --border: #24262c;
  --border-strong: #3a3d45;
  --accent: #ededf0;
  --accent-text: #0b0c0e;
  --danger: #e08a7a;
  --focus-ring: rgba(237, 237, 240, 0.45);
  --focus-halo: rgba(237, 237, 240, 0.08);
  --tile-bg: #000;
  --radius: 6px;
  --header-h: 56px;
  --gap: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f4f4f5;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #ececee;
  --text: #16171a;
  --text-dim: #5b5e66;
  --text-faint: #8a8d94;
  --border: #e0e1e4;
  --border-strong: #c7c9ce;
  --accent: #16171a;
  --accent-text: #f7f7f8;
  --danger: #a8422e;
  --focus-ring: rgba(22, 23, 26, 0.35);
  --focus-halo: rgba(22, 23, 26, 0.06);
}

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

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  background-color: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.15s ease, color 0.15s ease;
}

::selection {
  background: var(--text);
  color: var(--bg);
}

button {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

img,
video,
svg {
  display: block;
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

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

/* ------------------------------------------------------------------ header */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--header-h);
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar--bare {
  position: absolute;
  inset: 0 0 auto 0;
  justify-content: flex-end;
  background: transparent;
  border-bottom-color: transparent;
}

.wordmark {
  display: inline-block;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.34em;
  line-height: 1;
  text-transform: uppercase;
  color: var(--text);
  padding-left: 0.34em; /* optically centre the tracking */
  user-select: none;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

.icon-btn:active {
  transform: translateY(1px);
}

.icon-btn[disabled] {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

.icon {
  width: 18px;
  height: 18px;
}

/* The button shows the theme it will switch to. */
:root[data-theme="dark"] .icon--moon,
:root[data-theme="light"] .icon--sun {
  display: none;
}

/* --------------------------------------------------------------- app layout */

.page--app {
  background: var(--bg);
}

.app-main {
  padding: 16px;
  max-width: 1680px;
  margin: 0 auto;
}

.grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  align-content: start;
}

.grid-drop-indicator {
  position: absolute;
  z-index: 6;
  width: 3px;
  border-radius: 2px;
  background: var(--text);
  box-shadow: 0 0 0 2px var(--bg);
  pointer-events: none;
}

/* ------------------------------------------------------------------- tiles */

.tile {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: var(--tile-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
}

.grid > .tile {
  width: 100%;
  aspect-ratio: 16 / 9;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.grid > .tile:active {
  cursor: grabbing;
}

.grid > .tile:hover {
  border-color: var(--border-strong);
}

.grid > .tile[data-status="ended"] {
  cursor: grab;
}

.tile--dragging {
  z-index: 5;
  opacity: 0.88;
  cursor: grabbing;
  border-color: var(--border-strong);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  will-change: transform;
  transition: none;
}

.tile--drop-target {
  outline: 2px solid var(--border-strong);
  outline-offset: 3px;
}

body.is-grid-dragging,
body.is-grid-dragging .tile {
  cursor: grabbing;
}

body.is-grid-dragging {
  user-select: none;
  -webkit-user-select: none;
}

.tile__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--tile-bg);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.tile[data-state="playing"] .tile__video {
  opacity: 1;
}

.tile__poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.tile[data-poster="1"] .tile__poster {
  opacity: 1;
}

.tile[data-state="playing"] .tile__poster {
  opacity: 0;
}

.tile__placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.14);
  background: #050506;
  transition: opacity 0.18s ease;
}

.tile[data-state="playing"] .tile__placeholder,
.tile[data-poster="1"] .tile__placeholder,
.tile[data-status="ended"] .tile__placeholder {
  opacity: 0;
}

.tile__status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  text-transform: uppercase;
  text-align: center;
  color: rgba(255, 255, 255, 0.62);
  background: rgba(0, 0, 0, 0.42);
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}

.tile[data-state="error"] .tile__status {
  opacity: 1;
}

.tile__bar {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 26px 12px 10px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0));
  color: #fff;
  pointer-events: none;
}

.tile[data-status="ended"] .tile__bar {
  display: none;
}

.dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12);
}

.dot--live {
  animation: live-pulse 2.6s ease-in-out infinite;
}

@keyframes live-pulse {
  0%,
  100% {
    opacity: 0.9;
  }
  50% {
    opacity: 0.35;
  }
}

.tile__title {
  min-width: 0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile__ended {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 14px;
  text-align: center;
  color: #fff;
  background: rgba(5, 6, 7, 0.68);
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}

.tile[data-status="ended"] .tile__ended {
  opacity: 1;
}

.tile__ended-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.42);
}

.tile__ended-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.95);
}

.tile__ended-count {
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.55);
}

.tile--new {
  animation: tile-in 0.28s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

@keyframes tile-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ------------------------------------------------------------- focus mode */

.stage {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.stage__main {
  position: relative;
  width: 100%;
  width: min(100%, calc((100dvh - var(--header-h) - 150px) * 1.7778));
  max-width: 100%;
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--tile-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.stage__main:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.stage__main > .tile {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
  cursor: pointer;
}

.stage__main > .tile .tile__bar {
  padding-bottom: 14px;
}

.stage__main:fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  margin: 0;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
  background: #000;
  cursor: default;
}

.stage__main:fullscreen > .tile {
  cursor: default;
}

.stage__main:fullscreen .tile__video {
  object-fit: contain;
}

.stage__main:fullscreen .tile__bar {
  padding: 40px 20px 18px;
}

.stage__main:fullscreen .tile__title {
  font-size: 14px;
}

.stage__main:fullscreen .stage__sound,
.stage__main:fullscreen .stage__fullscreen {
  width: 40px;
  height: 40px;
}

.stage__main:fullscreen .stage__sound {
  right: 14px;
  bottom: 14px;
}

.stage__main:fullscreen .stage__fullscreen {
  right: 62px;
  bottom: 14px;
}

.stage__sound,
.stage__fullscreen {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(8, 9, 11, 0.66);
  color: #fff;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.stage__fullscreen {
  right: 52px;
}

.stage__sound:hover,
.stage__fullscreen:hover {
  background: rgba(8, 9, 11, 0.86);
  border-color: rgba(255, 255, 255, 0.4);
}

.stage__sound svg,
.stage__fullscreen svg {
  width: 16px;
  height: 16px;
}

.stage__rail {
  display: flex;
  gap: 8px;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 1px 1px 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.stage__rail::-webkit-scrollbar {
  height: 6px;
}

.stage__rail::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

.stage__rail > .tile {
  flex: 0 0 auto;
  width: clamp(112px, 15vw, 172px);
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  cursor: pointer;
}

.stage__rail > .tile:hover {
  border-color: var(--border-strong);
}

.stage__rail > .tile[data-status="ended"] {
  cursor: default;
}

.stage__rail > .tile .tile__bar {
  padding: 16px 8px 6px;
}

.stage__rail > .tile .tile__title {
  font-size: 10.5px;
}

.stage__rail > .tile .tile__ended-name {
  display: none;
}

.stage__rail > .tile .tile__ended {
  gap: 3px;
  padding: 8px;
}

.stage__rail > .tile .tile__ended-title {
  font-size: 9px;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
}

.stage__rail > .tile .tile__ended-count {
  font-size: 9px;
}

/* ------------------------------------------------------------ empty state */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: calc(100vh - var(--header-h) - 48px);
  min-height: calc(100dvh - var(--header-h) - 48px);
  padding: 24px;
  text-align: center;
}

.empty__mark {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  text-transform: uppercase;
  color: var(--text-faint);
  opacity: 0.6;
  margin-bottom: 8px;
}

.empty__title {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.empty__hint {
  margin: 0;
  max-width: 36ch;
  font-size: 12px;
  color: var(--text-faint);
}

/* -------------------------------------------------------------- ban screen */

.ban {
  display: grid;
  place-items: center;
  min-height: calc(100vh - var(--header-h));
  min-height: calc(100dvh - var(--header-h));
  padding: 24px;
  text-align: center;
}

.ban__box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 420px;
}

.ban__title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.ban__count {
  margin: 0;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}

/* ------------------------------------------------------------------- auth */

.page--auth .topbar {
  background: transparent;
  border-bottom-color: transparent;
}

.auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 84px 20px 48px;
}

.card {
  width: 100%;
  max-width: 352px;
  padding: 30px 26px 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.card__wordmark {
  display: block;
  margin: 0 0 26px;
  text-align: center;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.5em;
  line-height: 1;
  text-transform: uppercase;
  color: var(--text);
  padding-left: 0.5em;
  user-select: none;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: block;
}

.field__label {
  display: block;
  margin-bottom: 6px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-indent: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.field__input {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field__input::placeholder {
  color: var(--text-faint);
}

.field__input:hover {
  border-color: var(--border-strong);
}

.field__input:focus {
  outline: none;
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--focus-halo);
}

.field__input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.field__input--code {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.field__input--code::placeholder {
  letter-spacing: 0.12em;
  text-transform: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 38px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--accent-text);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.05s ease;
}

.btn:hover {
  opacity: 0.86;
}

.btn:active {
  transform: translateY(1px);
}

.btn[disabled] {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

.form-error {
  margin: 14px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--danger);
}

.form-error__count {
  display: block;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}

.switch {
  margin: 18px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
}

.link-btn {
  padding: 0;
  font-size: 12px;
  color: var(--text-dim);
  background: none;
  border: 0;
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--text);
  text-decoration-color: var(--border-strong);
}

/* ------------------------------------------------------------------ embed */

.page--embed {
  background: var(--bg);
  overflow: hidden;
}

.embed {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
}

.embed__frame {
  position: relative;
  width: min(100vw, calc(100dvh * 1.7778));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000;
}

.embed__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.embed[data-state="playing"] .embed__video {
  opacity: 1;
}

.embed__status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.66);
  background: rgba(0, 0, 0, 0.5);
}

.noscript {
  margin: 24px;
  font-size: 13px;
  color: var(--text-dim);
}

/* -------------------------------------------------------------- responsive */

@media (max-width: 640px) {
  :root {
    --gap: 8px;
  }

  .topbar {
    padding: 0 10px;
  }

  .app-main {
    padding: 10px;
  }

  .card {
    padding: 24px 20px 22px;
  }

  .stage__main {
    width: min(100%, calc((100dvh - var(--header-h) - 140px) * 1.7778));
  }

  .stage__rail > .tile {
    width: clamp(96px, 30vw, 140px);
  }

  .tile__ended {
    gap: 3px;
    padding: 8px;
  }

  .tile__ended-title {
    font-size: 9px;
    letter-spacing: 0.16em;
    text-indent: 0.16em;
  }

  .tile__ended-count {
    font-size: 9px;
  }
}
