/* атаракс — viewer page. Tokens from the Claude Design handoff ("атаракс · дизайн v1"). */

/* JetBrains Mono cyrillic */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url(fonts/jetbrains-mono-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* JetBrains Mono latin */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url(fonts/jetbrains-mono-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Onest cyrillic */
@font-face {
  font-family: 'Onest';
  font-style: normal;
  font-weight: 300 600;
  font-display: swap;
  src: url(fonts/onest-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* Onest latin */
@font-face {
  font-family: 'Onest';
  font-style: normal;
  font-weight: 300 600;
  font-display: swap;
  src: url(fonts/onest-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* поверхности */
  --atx-bg: #050506;
  --atx-surface-1: #0b0b0e;
  --atx-surface-card: #0e0e11;
  --atx-surface-2: #17171b;
  --atx-surface-3: #2a2a30;
  --atx-line: rgba(255, 255, 255, .08);
  --atx-line-2: rgba(255, 255, 255, .07);
  /* текст */
  --atx-text: #f3f1ec;
  --atx-text-2: #a19ea8;
  --atx-text-3: #6c6a73;
  --atx-ink: #0a0a0c;
  /* сигналы */
  --atx-live: #ff3352;
  --atx-ok: #5be38a;
  --atx-warn: #ffc847;
  --atx-bad: #ff4d5e;
  --atx-error: #ff6b7a;
  /* оверлеи поверх видео — без blur */
  --atx-scrim: rgba(5, 5, 6, .72);
  --atx-plate: rgba(8, 8, 10, .74);
  --atx-ctl: rgba(255, 255, 255, .1);
  /* градиенты */
  --atx-grad-ember:
    radial-gradient(70% 80% at 85% 105%, #ffb23d 0%, rgba(255, 178, 61, 0) 60%),
    radial-gradient(70% 90% at 0% 0%, #ff2d7a 0%, rgba(255, 45, 122, 0) 65%),
    linear-gradient(160deg, #a3124d 0%, #3a0a24 100%);
  --atx-grad-ember-wide:
    radial-gradient(60% 120% at 90% 120%, #ffb23d 0%, rgba(255, 178, 61, 0) 60%),
    radial-gradient(70% 140% at 0% 0%, #ff2d7a 0%, rgba(255, 45, 122, 0) 70%),
    linear-gradient(160deg, #a3124d, #3a0a24);
  --atx-grad-offline:
    radial-gradient(70% 80% at 85% 100%, #ffb23d 0%, rgba(255, 178, 61, 0) 60%),
    radial-gradient(70% 90% at 0% 0%, #ff2d7a 0%, rgba(255, 45, 122, 0) 65%),
    linear-gradient(160deg, #a3124d 0%, #2a0619 100%);
  --atx-grad-signal:
    radial-gradient(40% 55% at 50% 50%, #dfeaff 0%, rgba(223, 234, 255, 0) 45%),
    radial-gradient(80% 90% at 15% 110%, #3fd0ff 0%, rgba(63, 208, 255, 0) 60%),
    radial-gradient(70% 80% at 100% 0%, #6a3dff 0%, rgba(106, 61, 255, 0) 60%),
    linear-gradient(170deg, #1838e0, #071044);
  --atx-grad-own:
    radial-gradient(80% 140% at 10% 120%, #3fd0ff 0%, rgba(63, 208, 255, 0) 60%),
    radial-gradient(70% 120% at 100% 0%, #6a3dff 0%, rgba(106, 61, 255, 0) 60%),
    linear-gradient(170deg, #1838e0, #0d1a7a);
  --atx-own-ink: #ffffff;
  --atx-grad-cta: linear-gradient(95deg, #ff4f9a 0%, #ff8a4c 100%);
  --atx-grad-dot:
    radial-gradient(70% 70% at 70% 80%, #ffb23d 0%, rgba(255, 178, 61, 0) 70%),
    linear-gradient(150deg, #ff2d7a, #a3124d);
  --atx-grad-volume: linear-gradient(90deg, #ff2d7a, #ffb23d);
  /* шрифты */
  --atx-font: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --atx-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  /* форма */
  --atx-r-xs: 6px;
  --atx-r-s: 12px;
  --atx-r-m: 16px;
  --atx-r-l: 24px;
  --atx-r-xl: 32px;
  --atx-r-pill: 999px;
  --atx-hit: 44px;
  --atx-chat-w: 360px;
  --atx-header-h: 52px;
  --atx-shadow-pop: 0 12px 40px rgba(0, 0, 0, .45);

  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { background: var(--atx-bg); }
body {
  margin: 0;
  background: var(--atx-bg);
  color: var(--atx-text);
  font: 400 15px/1.4 var(--atx-font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
input::placeholder { color: var(--atx-text-3); }
:focus-visible { outline: 2px solid #ff8fb8; outline-offset: 2px; }

.icon {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.icon-md { width: 18px; height: 18px; }
.icon-sm { width: 16px; height: 16px; }
.icon-xs { width: 15px; height: 15px; }

/* ---------- Вход ---------- */
.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  padding-top: max(24px, env(safe-area-inset-top));
  background:
    radial-gradient(34% 48% at 50% 62%, rgba(255, 45, 122, .32) 0%, rgba(255, 45, 122, 0) 70%),
    radial-gradient(26% 36% at 62% 34%, rgba(255, 170, 60, .22) 0%, rgba(255, 170, 60, 0) 70%),
    radial-gradient(28% 40% at 36% 38%, rgba(90, 70, 255, .22) 0%, rgba(90, 70, 255, 0) 70%),
    var(--atx-bg);
}
.login-card {
  width: 100%;
  max-width: 420px;
  border-radius: var(--atx-r-xl);
  background: var(--atx-surface-card);
  border: 1px solid rgba(255, 255, 255, .09);
  overflow: hidden;
  box-shadow: 0 40px 120px rgba(0, 0, 0, .6);
}
.login-hero {
  height: 200px;
  padding: 22px 26px 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--atx-grad-ember);
}
.login-kicker {
  font: 500 11px/1 var(--atx-mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .75);
}
.login-hero-text { display: flex; flex-direction: column; gap: 8px; }
.login-title { margin: 0; font: 600 48px/0.95 var(--atx-font); letter-spacing: -0.05em; }
.login-sub { margin: 0; font-size: 15px; color: rgba(255, 255, 255, .85); }
.login-body { padding: 24px 26px 26px; display: flex; flex-direction: column; gap: 16px; }
.field-wrap { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 13px; color: var(--atx-text-2); }
.field {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border-radius: var(--atx-r-m);
  border: 1px solid var(--atx-line);
  background: var(--atx-surface-2);
  color: var(--atx-text);
  font: 400 16px var(--atx-font);
  outline: none;
}
.field:focus, .field:focus-within { border-color: rgba(255, 143, 184, .5); }
.field.is-error { border-color: var(--atx-bad); }
.field-row { display: flex; align-items: center; padding: 0 6px 0 16px; }
.field-row input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; background: transparent; color: var(--atx-text);
  font: 400 16px var(--atx-font); outline: none; padding: 0;
}
.pw-toggle {
  height: 40px;
  padding: 0 12px;
  border-radius: var(--atx-r-s);
  border: 0;
  background: transparent;
  color: var(--atx-text-2);
  display: flex; align-items: center; gap: 6px;
  font: 500 13px var(--atx-font);
}
.login-error { margin: 0; font-size: 13.5px; line-height: 1.4; color: var(--atx-error); }
.btn-cta {
  margin-top: 6px;
  height: 54px;
  border-radius: var(--atx-r-pill);
  border: 0;
  background: var(--atx-grad-cta);
  color: #1a0610;
  font: 600 16px var(--atx-font);
}
.btn-cta:disabled { opacity: .6; cursor: progress; }

/* ---------- Комната ---------- */
.room {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--atx-chat-w);
  grid-template-rows: var(--atx-header-h) minmax(0, 1fr);
  grid-template-areas: "top top" "player chat";
}
.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--atx-line-2);
  min-width: 0;
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand {
  display: flex; align-items: center; gap: 9px;
  font: 600 17px/1 var(--atx-font);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.brand-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--atx-grad-dot); flex: none; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px;
  padding: 0 9px;
  border-radius: var(--atx-r-pill);
  background: var(--atx-surface-3);
  color: var(--atx-text-2);
  font: 600 11px/1 var(--atx-mono);
  letter-spacing: .08em;
  white-space: nowrap;
}
.badge[data-state="wait"] { padding: 0 10px; letter-spacing: .2em; }
.badge[data-state="live"], .badge-live { background: var(--atx-live); color: #fff; }
.badge[data-state="live"]::before, .badge-live::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff;
}
.viewers {
  display: inline-flex; align-items: center; gap: 8px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--atx-r-pill);
  background: var(--atx-surface-2);
  font-size: 13px;
  color: #d9d6de;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---------- Плеер ---------- */
.player {
  grid-area: player;
  position: relative;
  background: #000;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  container-type: size;
}
.frame {
  position: relative;
  width: min(100cqw, 100cqh * 16 / 9);
  aspect-ratio: 16 / 9;
  max-width: 100%;
  overflow: hidden;
}
.frame video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  background: #000;
}
.player:fullscreen { width: 100vw; height: 100vh; }

.overlay {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}
.overlay strong { font: 600 22px/1.1 var(--atx-font); letter-spacing: -0.02em; }
.player[data-state="connecting"] .overlay-connecting,
.player[data-state="offline"] .overlay-offline,
.player[data-state="reconnecting"] .overlay-reconnecting { display: flex; }

.overlay-connecting { gap: 18px; background: var(--atx-grad-signal); color: #0a1250; }
.overlay-reconnecting { gap: 16px; background: var(--atx-scrim); }
.overlay-text { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.overlay-text span { font-size: 15px; color: var(--atx-text-2); }
.overlay-offline {
  align-items: flex-start;
  justify-content: flex-end;
  text-align: left;
  gap: 10px;
  padding: clamp(20px, 4cqw, 48px);
  background: var(--atx-grad-offline);
}
.overlay-offline strong { font-size: clamp(16px, 2.2cqw, 26px); line-height: 1.2; }
.overlay-offline span { font-size: clamp(13px, 1.4cqw, 16px); color: rgba(255, 255, 255, .8); }
.overlay-offline .offline-big {
  font: 300 clamp(52px, 10cqw, 120px)/0.9 var(--atx-font);
  letter-spacing: -0.06em;
  color: rgba(255, 255, 255, .92);
}

.spinner {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 3px solid rgba(243, 241, 236, .18);
  border-top-color: var(--atx-text);
  animation: atx-spin .9s linear infinite;
}
.spinner-dark { border-color: rgba(10, 18, 80, .2); border-top-color: #0a1250; }
@keyframes atx-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

.unmute {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  height: 60px;
  padding: 0 28px 0 22px;
  border-radius: var(--atx-r-pill);
  border: 0;
  background: var(--atx-text);
  color: var(--atx-ink);
  display: flex; align-items: center; gap: 12px;
  font: 600 17px var(--atx-font);
  box-shadow: var(--atx-shadow-pop);
  white-space: nowrap;
}
.unmute .icon { width: 22px; height: 22px; }
.unmute-short { display: none; }

.stats {
  position: absolute; left: 16px; top: 16px;
  z-index: 2;
  padding: 12px 14px;
  border-radius: var(--atx-r-s);
  background: var(--atx-plate);
  border: 1px solid var(--atx-line);
  display: grid;
  grid-template-columns: auto auto;
  column-gap: 22px;
  row-gap: 5px;
  font: 400 12px/1.35 var(--atx-mono);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.stats .k { color: #8d8a93; }
.stats .v { color: var(--atx-text); text-align: right; }
.stats .ok { color: var(--atx-ok); }
.stats .warn { color: var(--atx-warn); }
.stats .bad { color: var(--atx-bad); }

.controls {
  position: absolute; left: 0; right: 0; bottom: 0;
  z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 48px 16px 14px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(0deg, rgba(0, 0, 0, .8), rgba(0, 0, 0, 0));
  color: var(--atx-text);
  transition: opacity .25s;
}
.controls-group { display: flex; align-items: center; gap: 10px; }
.controls-group:last-child { gap: 8px; }
.player.idle .controls { opacity: 0; pointer-events: none; }
.player.idle { cursor: none; }
.player:not([data-state="live"]):not([data-state="reconnecting"]) .controls,
.player:not([data-state="live"]):not([data-state="reconnecting"]) .stats { display: none; }
.ctl {
  min-width: 40px; height: 40px;
  border-radius: var(--atx-r-s);
  border: 0;
  background: var(--atx-ctl);
  color: var(--atx-text);
  display: inline-flex; align-items: center; justify-content: center;
}
.ctl:hover { background: rgba(255, 255, 255, .16); }
.ctl-text { padding: 0 14px; gap: 8px; font: 500 14px var(--atx-font); }
.ctl-text[aria-pressed="true"] { background: var(--atx-text); color: var(--atx-ink); }
.controls-live { display: none; }

.volume {
  --pct: 100%;
  --fill-opacity: 1;
  width: 128px;
  height: 28px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.volume::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 4px;
  background:
    linear-gradient(90deg, #ff2d7a, #ffb23d) 0 0 / var(--pct) 100% no-repeat,
    rgba(255, 255, 255, .2);
}
.volume::-moz-range-track { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .2); }
.volume::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--atx-grad-volume); opacity: var(--fill-opacity); }
.volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  margin-top: -5px;
  border-radius: 50%;
  border: 0;
  background: var(--atx-text);
}
.volume::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; border: 0; background: var(--atx-text); }
.volume.is-muted::-webkit-slider-runnable-track {
  background:
    linear-gradient(90deg, rgba(255, 45, 122, .35), rgba(255, 178, 61, .35)) 0 0 / var(--pct) 100% no-repeat,
    rgba(255, 255, 255, .2);
}
.volume.is-muted { --fill-opacity: .35; }

/* ---------- Чат ---------- */
.chat {
  grid-area: chat;
  position: relative;
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--atx-surface-1);
  border-left: 1px solid var(--atx-line-2);
}
.chat-head {
  margin: 12px 12px 0;
  height: 76px;
  flex: none;
  border-radius: 20px;
  padding: 14px 18px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: var(--atx-grad-ember-wide);
}
.chat-title { font: 600 20px/1 var(--atx-font); letter-spacing: -0.02em; }
.chat-sub { font-size: 12px; color: rgba(255, 255, 255, .75); }
.chat-status {
  margin: 10px 12px 0;
  padding: 10px 14px;
  border-radius: 14px;
  background: #1d1a12;
  border: 1px solid rgba(255, 200, 71, .25);
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
  color: #ffd77a;
}
.chat-status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--atx-warn); flex: none; }
.chat-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.messages {
  list-style: none;
  margin: 0;
  padding: 16px 16px 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}
.msg { display: flex; flex-direction: column; gap: 5px; align-items: flex-start; max-width: 86%; }
.msg-head { display: flex; gap: 8px; align-items: baseline; padding: 0 2px; }
.msg-nick { font: 600 13px var(--atx-font); }
.msg-time { font: 400 11px var(--atx-mono); color: var(--atx-text-3); }
.msg-bubble {
  background: var(--atx-surface-2);
  border-radius: 6px 18px 18px 18px;
  padding: 9px 13px;
  font-size: 14.5px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.me .msg-bubble { background: var(--atx-grad-own); color: var(--atx-own-ink); border-radius: 18px 6px 18px 18px; }
.msg-system {
  align-self: center;
  padding: 2px 0;
  font: 400 11px/1.4 var(--atx-mono);
  color: var(--atx-text-3);
  text-align: center;
}
.chat-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px;
  text-align: center;
  font: 500 15px/1.4 var(--atx-font);
  color: var(--atx-text-2);
  pointer-events: none;
}
.chat-empty-orb {
  width: 88px; height: 88px; border-radius: 50%;
  background:
    radial-gradient(50% 50% at 50% 55%, #2e6b3a 0%, rgba(46, 107, 58, 0) 80%),
    linear-gradient(160deg, #ff8a7a, #ff5fa2 55%, #f0b37a);
}
.new-msgs {
  position: absolute; left: 50%; bottom: 10px;
  transform: translateX(-50%);
  height: 36px;
  padding: 0 16px;
  border-radius: var(--atx-r-pill);
  border: 0;
  background: var(--atx-text);
  color: var(--atx-ink);
  font: 600 13px var(--atx-font);
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}
.chat-form {
  flex: none;
  display: flex; gap: 8px;
  padding: 10px 12px 14px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
}
.chat-form:has(.chat-input:disabled) { opacity: .4; }
.chat-input { flex: 1; min-width: 0; height: 46px; font-size: 15px; }
.chat-send {
  width: 46px; height: 46px; flex: none;
  border-radius: var(--atx-r-m);
  border: 0;
  background: var(--atx-grad-own);
  color: var(--atx-own-ink);
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Телефон вертикально / узкий экран ---------- */
@media (max-width: 900px) {
  .room { display: flex; flex-direction: column; height: 100dvh; }
  .topbar {
    flex: none;
    border-bottom: 0;
    padding: 0 16px;
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(var(--atx-header-h) + env(safe-area-inset-top, 0px));
  }
  .topbar-left { gap: 10px; }
  .viewers { gap: 6px; padding: 0 11px; }
  .viewers-word { display: none; }
  .player { flex: none; width: 100%; aspect-ratio: 16 / 9; }
  .chat { flex: 1; border-left: 0; background: var(--atx-bg); }
  .chat-head { height: 56px; border-radius: 18px; flex-direction: row; align-items: center; padding: 0 16px; }
  .chat-title { font-size: 18px; }
  .chat-sub { display: none; }
  .messages { gap: 12px; padding: 12px 16px 8px; }
  .msg-bubble { font-size: 15px; }
  .chat-form { padding: 12px 12px 14px; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  .chat-input, .chat-send { height: 48px; }
  .chat-input { font-size: 16px; }
  .chat-send { width: 48px; }
  .unmute { height: 48px; padding: 0 20px 0 16px; gap: 8px; font-size: 15px; }
  .unmute .icon { width: 18px; height: 18px; }
  .unmute-long { display: none; }
  .unmute-short { display: inline; }
  .stats { left: 10px; top: 10px; padding: 10px 12px; column-gap: 18px; row-gap: 3px; font-size: 11px; }
  .controls { padding: 32px 12px 10px; }
}

/* Сенсорные экраны: громкость кнопками телефона */
@media (hover: none) {
  .volume { display: none; }
  .ctl { min-width: var(--atx-hit); height: var(--atx-hit); border-radius: 14px; background: rgba(255, 255, 255, .12); }
}

/* ---------- Телефон горизонтально: только видео ---------- */
@media (orientation: landscape) and (max-height: 500px) {
  .room { display: block; height: 100dvh; }
  .topbar, .chat { display: none; }
  .player { position: fixed; inset: 0; aspect-ratio: auto; }
  .player[data-state="live"] .controls-live { display: inline-flex; }
  .controls { padding: 40px 16px 16px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
}
