@font-face {
  font-family: "Rehab Plex";
  src: url("assets/fonts/IBMPLEXSANS-REGULAR.TTF") format("truetype");
  font-weight: 400;
}

@font-face {
  font-family: "Rehab Plex";
  src: url("assets/fonts/IBMPLEXSANS-BOLD.TTF") format("truetype");
  font-weight: 700;
}

:root {
  color-scheme: dark;
  --ink: #070b12;
  --panel: #0c1420;
  --panel-2: #101a29;
  --paper: #f7fbff;
  --muted: rgba(255, 255, 255, 0.62);
  --blue: #3366ff;
  --blue-deep: #064ed0;
  --green: #17e316;
  --line: rgba(51, 102, 255, 0.3);
  --grid-line: rgba(51, 102, 255, 0.08);
  --danger: #ff5449;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Rehab Plex", Arial, sans-serif;
  background:
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    linear-gradient(0deg, var(--grid-line) 1px, transparent 1px),
    var(--ink);
  background-size: 48px 48px, 48px 48px, auto;
  color: var(--paper);
  line-height: 1.4;
}

button, input, textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 0;
  padding: 11px 16px;
  background: var(--green);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.94);
}

button:disabled {
  opacity: 0.5;
  cursor: wait;
}

button.button-danger {
  background: var(--danger);
  color: var(--paper);
}

input, textarea {
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(51, 102, 255, 0.52);
  border-radius: 0;
  padding: 12px 2px;
  background: transparent;
  color: var(--paper);
}

input::placeholder, textarea::placeholder {
  color: rgba(255, 255, 255, 0.38);
}

input:focus, textarea:focus {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--paper);
  caret-color: var(--paper);
  box-shadow: 0 0 0 1000px var(--panel) inset;
  transition: background-color 9999s ease-in-out 0s;
}

textarea { resize: none; }

.webinar-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  height: 100vh;
  padding: 18px;
  overflow: hidden;
}

.stage, .side section {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
}

.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  min-width: 0;
  min-height: 0;
}

.stage-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
}

.brand {
  display: inline-block;
}

.brand img {
  width: 176px;
  height: auto;
  display: block;
  mix-blend-mode: screen;
}

.stage-date {
  display: inline-block;
  margin: 0 0 8px;
  padding: 4px 10px;
  background: var(--green);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.eyebrow, .form-note, .status { color: var(--muted); margin: 0; }

.eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "/ ";
  color: var(--green);
}

.stage-head h1 {
  margin: 0;
  font-size: clamp(20px, 2.4vw, 34px);
  line-height: 1.08;
  font-weight: 700;
  text-transform: uppercase;
}

.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.live-pill, .viewer-pill, .ping-pill {
  border: 1px solid var(--line);
  padding: 9px 13px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.live-pill.is-live {
  color: var(--ink);
  background: var(--green);
  border-color: var(--green);
}

.live-pill.is-test {
  color: var(--ink);
  background: #ffd85a;
  border-color: #ffd85a;
}

.live-pill.is-test::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--ink);
}

.live-pill.is-live::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--ink);
  animation: live-blink 1.4s ease-in-out infinite;
}

@keyframes live-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.live-pill.is-ended {
  color: var(--paper);
  background: var(--danger);
  border-color: var(--danger);
}

.viewer-pill, .ping-pill {
  color: var(--paper);
  background: rgba(51, 102, 255, 0.14);
}

.ping-pill.is-ok {
  border-color: rgba(23, 227, 22, 0.55);
  color: var(--green);
}

.ping-pill.is-warn {
  border-color: rgba(255, 200, 60, 0.6);
  color: #ffc83c;
}

.ping-pill.is-bad {
  border-color: rgba(255, 84, 73, 0.65);
  color: #ffaBa5;
}

.video-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  align-content: center;
  flex: 1;
  min-height: 56vh;
  height: 100%;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #020509;
}

.video-grid.stage-mode-one,
.video-grid.stage-mode-voice {
  grid-template-columns: minmax(0, 1fr);
}

.video-grid.stage-mode-one .video-tile,
.video-grid.stage-mode-voice .video-tile {
  display: grid;
  place-items: center;
}

.video-tile {
  position: relative;
  min-height: 260px;
  background: #020509;
}

.video-tile video {
  width: 100%;
  height: 100%;
  min-height: 260px;
  object-fit: cover;
  display: block;
}

.video-grid.stage-mode-one .video-tile video,
.video-grid.stage-mode-voice .video-tile video {
  width: auto;
  max-width: 100%;
  height: 100%;
  object-fit: contain;
  background: #020509;
}

.video-tile span {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 6px 10px;
  background: rgba(7, 11, 18, 0.85);
  border: 1px solid rgba(23, 227, 22, 0.44);
  color: var(--paper);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.video-tile .mic-indicator {
  left: auto;
  right: 12px;
  top: 12px;
  bottom: auto;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-left: 0;
  background: rgba(255, 84, 73, 0.92);
}

.video-tile.mic-active .mic-indicator {
  background: var(--green);
  color: var(--ink);
}

.video-tile.screen-sharing::after {
  content: "Экран";
  position: absolute;
  left: 12px;
  top: 12px;
  padding: 6px 10px;
  background: var(--blue);
  color: var(--paper);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.empty-stage {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 56vh;
  text-align: center;
  color: var(--muted);
  padding: 24px;
}

.empty-stage strong {
  color: var(--paper);
  font-size: clamp(22px, 2.6vw, 30px);
  line-height: 1.15;
  text-transform: uppercase;
}

.empty-stage strong::before {
  content: "/ ";
  color: var(--green);
}

.video-grid.is-ended .video-tile {
  display: none;
}

.video-grid.is-ended .empty-stage {
  min-height: 62vh;
}

.video-grid.is-ended .empty-stage strong {
  max-width: 760px;
  font-size: 34px;
}

.video-grid.is-ended .empty-stage span {
  max-width: 820px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 18px;
  line-height: 1.45;
}

.viewer-controls, .control-row, .director-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.control-deck {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 14px;
  border: 1px solid rgba(51, 102, 255, 0.32);
  background: rgba(51, 102, 255, 0.08);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.36);
}

.control-row {
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
  justify-content: center;
}

.control-row[hidden] {
  display: none !important;
}

.host-controls {
  flex: 0 1 auto;
}

.admin-controls {
  flex: 0 1 auto;
}

.control-row button,
.viewer-controls button {
  min-height: 38px;
  padding: 10px 14px;
  white-space: nowrap;
}

.viewer-controls {
  justify-content: flex-start;
}

.viewer-controls button {
  background: var(--green);
  color: var(--ink);
}

.admin-controls button {
  background: transparent;
  color: var(--paper);
  border: 1px solid var(--line);
}

.director-controls {
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: rgba(51, 102, 255, 0.06);
}

.director-controls[hidden] {
  display: none !important;
}

.director-controls > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.segmented-control {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.segmented-control button {
  padding: 9px 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--paper);
  font-size: 12px;
}

.segmented-control button.is-active {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--paper);
}

.status {
  font-size: 14px;
}

.hall-question {
  position: absolute;
  left: 50%;
  right: auto;
  bottom: 52px;
  width: min(620px, calc(100% - 72px));
  transform: translateX(-50%);
  z-index: 5;
  border: 1px solid rgba(23, 227, 22, 0.65);
  background: rgba(7, 11, 18, 0.88);
  padding: clamp(9px, 1.2vw, 13px) clamp(12px, 1.6vw, 18px);
  box-shadow: 0 0 0 1px rgba(23, 227, 22, 0.2), 0 14px 42px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(2px);
}

.hall-question p {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hall-question strong {
  display: block;
  color: var(--paper);
  font-size: clamp(16px, 1.55vw, 22px);
  line-height: 1.22;
}

.hall-question-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(51, 102, 255, 0.06);
}

.hall-question-form[hidden] {
  display: none !important;
}

.hall-question-form label {
  display: grid;
  gap: 7px;
}

.hall-question-form label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hall-question-form textarea {
  min-height: 54px;
  max-height: 110px;
  border: 1px solid rgba(51, 102, 255, 0.38);
  background: rgba(51, 102, 255, 0.07);
  padding: 10px;
}

.hall-question-form button[type="button"] {
  border: 1px solid rgba(255, 84, 73, 0.55);
  background: transparent;
  color: #ffaba5;
}

@media (max-width: 1200px) {
  .hall-question-form {
    grid-template-columns: 1fr 1fr;
  }
  .hall-question-form label {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  .hall-question {
    bottom: 48px;
    width: calc(100% - 28px);
  }
}

.side {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 18px;
  align-content: start;
  min-height: 0;
  overflow: hidden;
}

.side section {
  padding: 20px;
}

.join-card h2, .chat-head h2 {
  margin: 6px 0 16px;
  font-size: 20px;
  line-height: 1.15;
  text-transform: uppercase;
}

.chat-head h2 {
  margin-bottom: 5px;
}

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

.join-card form, .chat-form { display: grid; gap: 12px; }

.join-card button[type="submit"],
.chat-form button[type="submit"] {
  margin-top: 6px;
}

.form-note { margin-top: 14px; font-size: 13px; line-height: 1.45; }

.chat-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  height: auto;
  min-height: 0;
  overflow: hidden;
}

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

.chat-head span {
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.chat-head-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
  min-width: 90px;
}

.chat-head-actions button {
  padding: 8px 10px;
  font-size: 12px;
}

.messages {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: 10px;
  overflow-x: hidden;
  overflow-y: scroll;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  padding: 12px 6px 12px 0;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--blue) rgba(255, 255, 255, 0.07);
}

.messages::-webkit-scrollbar,
.moderation-list::-webkit-scrollbar {
  width: 8px;
}

.messages::-webkit-scrollbar-track,
.moderation-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.07);
}

.messages::-webkit-scrollbar-thumb,
.moderation-list::-webkit-scrollbar-thumb {
  background: var(--blue);
}

.message {
  border: 1px solid rgba(51, 102, 255, 0.26);
  padding: 13px 14px;
  background: rgba(51, 102, 255, 0.08);
}

.message.is-new {
  animation: message-highlight 2.4s ease-out both;
}

@keyframes message-highlight {
  0% {
    border-color: rgba(23, 227, 22, 0.95);
    background: rgba(23, 227, 22, 0.24);
    box-shadow: 0 0 0 1px rgba(23, 227, 22, 0.55), 0 0 34px rgba(23, 227, 22, 0.22);
    transform: translateY(4px);
  }
  30% {
    border-color: rgba(51, 102, 255, 0.78);
    background: rgba(51, 102, 255, 0.18);
    box-shadow: 0 0 0 1px rgba(51, 102, 255, 0.35), 0 0 22px rgba(51, 102, 255, 0.16);
    transform: translateY(0);
  }
  100% {
    border-color: rgba(51, 102, 255, 0.26);
    background: rgba(51, 102, 255, 0.08);
    box-shadow: none;
    transform: translateY(0);
  }
}

.message.is-empty {
  background: rgba(255, 255, 255, 0.04);
}

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 7px;
}

.message-meta strong {
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.message-meta span {
  color: rgba(255, 255, 255, 0.42);
  font-size: 12px;
  white-space: nowrap;
}

.message p {
  margin: 0;
  color: rgba(247, 251, 255, 0.78);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.message button {
  margin-top: 8px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid rgba(255, 84, 73, 0.55);
  color: #ffaba5;
  font-size: 11px;
}

.moderation-list {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-bottom: 10px;
  max-height: 120px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--blue) rgba(255, 255, 255, 0.07);
}

.moderation-list strong {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.chat-form textarea {
  max-height: 150px;
  border: 0;
  border: 1px solid rgba(51, 102, 255, 0.36);
  background: rgba(51, 102, 255, 0.08);
  padding: 12px;
}

.chat-form button[type="submit"] {
  width: 100%;
}

.moderation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(51, 102, 255, 0.16);
}

.moderation-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.moderation-row button {
  padding: 7px 10px;
  border: 1px solid rgba(255, 84, 73, 0.55);
  background: transparent;
  color: #ffaba5;
  font-size: 11px;
}

@media (max-width: 900px) {
  .webinar-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    overflow: visible;
    padding: 10px;
  }
  .control-deck {
    padding: 10px;
  }
  .stage-head { grid-template-columns: 1fr; gap: 12px; }
  .status-pills { justify-content: flex-start; }
  .brand { justify-self: start; }
  .control-deck,
  .control-row {
    flex-wrap: wrap;
  }
  .control-row button {
    flex: 1 1 132px;
  }
  .chat-card {
    height: min(72vh, 620px);
    min-height: 430px;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
  }
  .messages {
    min-height: 0;
    max-height: none;
  }
}
