/* Здесь задаю базовые цвета и шрифт. Для повторяющихся цветов использую переменные. */
:root {
  color-scheme: dark;
  --bg: #111114;
  --panel: #18181d;
  --soft: #202026;
  --line: #2b2b32;
  --text: #f5f2f3;
  --muted: #a5a3af;
  --accent: #e83961;
  --light: #ff6c8c;
  font-family: Inter, 'Segoe UI', Arial, sans-serif;
  font-size: 16px;
}

/* Считаю размеры элементов вместе с внутренними отступами и рамкой. */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  transition:
    background 0.18s,
    transform 0.18s;
  border: 0;
  color: inherit;
}

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

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

/* Оставляю видимую рамку фокуса для навигации с клавиатуры. */
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--light);
  outline-offset: 4px;
}

input {
  width: 100%;
  border: 1px solid #393840;
  background: #16161b;
  color: var(--text);
  border-radius: 9px;
  padding: 14px 16px;
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px #e8396118;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin: 24px 0;
}

label input {
  margin-top: 10px;
}

small {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 400;
  margin-top: 7px;
}

h1,
h2,
p {
  margin-top: 0;
}

.muted {
  color: var(--muted);
  line-height: 1.7;
}

.small {
  font-size: 0.875rem;
}

.eyebrow {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.17em;
  color: #ce8e9e;
}

.primary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--accent);
  border-radius: 9px;
  padding: 15px 21px;
  font-weight: 600;
}

.primary span {
  font-size: 1.3rem;
}

.error {
  color: #ff8a9f;
  font-size: 0.875rem;
  line-height: 1.5;
  min-height: 1.3em;
}

.link {
  background: transparent;
  color: var(--light);
  padding: 0;
}

/* Разделяю страницу входа на блок с описанием и форму с помощью Grid. */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.identity {
  position: relative;
  overflow: hidden;
  min-height: 760px;
  padding: 46px 56px;
  background: radial-gradient(ellipse at 0% 80%, #4d1427 0%, transparent 65%), #181418;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: white;
  text-decoration: none;
  font-size: 1.6rem;
  letter-spacing: -0.04em;
}

.brand img {
  width: 43px;
  height: 43px;
}

.brand span {
  color: var(--accent);
  margin-left: 6px;
}

.identity-copy {
  z-index: 1;
  margin-top: auto;
  padding: 65px 0 20px;
}

.identity h1 {
  font-size: clamp(3.4rem, 5.5vw, 6.7rem);
  line-height: 1.04;
  letter-spacing: -0.065em;
  margin: 22px 0 30px;
}

.identity h1 em {
  font-style: normal;
  color: var(--light);
}

.identity-copy p {
  font-size: 1.1rem;
  color: #c5b3bc;
  line-height: 1.65;
}

.identity footer {
  margin-top: auto;
  padding-top: 75px;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  display: flex;
  justify-content: space-between;
  color: #b99fa9;
}

/* Собираю декоративную звуковую волну из полосок разной высоты. */
.soundwave {
  position: absolute;
  right: -40px;
  bottom: 170px;
  height: 240px;
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0.2;
  transform: rotate(-18deg);
}

.soundwave i {
  background: #ec325e;
  width: 13px;
  height: 65px;
  border-radius: 20px;
}

.soundwave i:nth-child(3n) {
  height: 200px;
}

.soundwave i:nth-child(2n) {
  height: 125px;
}

.soundwave i:nth-child(5n) {
  height: 230px;
}

.auth-pane {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 70px 50px;
  position: relative;
}

.auth-card {
  width: min(100%, 380px);
}

.auth-card h2 {
  font-size: 2rem;
  letter-spacing: -0.035em;
  margin: 17px 0 12px;
}

.auth-card .primary {
  width: 100%;
}

.auth-switch {
  border-top: 1px solid var(--line);
  margin-top: 32px;
  padding-top: 25px;
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted);
}

.auth-foot {
  position: absolute;
  bottom: 34px;
  font-size: 0.8rem;
  color: #73717c;
}

/* Задаю колонки приложения: серверы, каналы, основная область и участники. */
.workspace {
  display: grid;
  grid-template-columns: 80px 248px minmax(0, 1fr) 230px;
  min-height: 100dvh;
}

.rail {
  background: #101013;
  border-right: 1px solid #25242b;
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 12px;
  padding: 24px 10px;
}

.rail-logo {
  width: 48px;
}

.rail-line {
  width: 28px;
  height: 1px;
  background: var(--line);
  margin: 8px 0;
}

.server-icon {
  width: 48px;
  height: 48px;
  background: #27252d;
  border-radius: 17px;
  display: block;
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 1rem;
}

.server-icon.selected {
  background: var(--accent);
  border-radius: 14px;
  box-shadow: -15px 0 0 -11px #fff;
}

.server-icon.add {
  background: #37202a;
  color: var(--light);
  font-size: 1.8rem;
}

.server-icon.join {
  background: transparent;
  border: 1px dashed #49404b;
  color: #b7acb9;
}

.rail-bottom {
  margin-top: auto;
  color: #5d5763;
  font-size: 0.75rem;
}

/* В этой панели располагаю каналы выбранного сервера. */
.sidebar {
  background: var(--panel);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
}

.sidebar header {
  min-height: 85px;
  padding: 25px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar header strong {
  overflow-wrap: anywhere;
}

.edition {
  font-size: 0.65rem;
  color: #b6a4af;
  border: 1px solid #49404b;
  border-radius: 4px;
  padding: 3px;
}

.sidebar-body {
  padding: 24px 14px;
  flex: 1;
}

.invite {
  width: 100%;
  padding: 12px;
  background: #292028;
  color: #edb4c3;
  border: 1px solid #44303b;
  border-radius: 8px;
  text-align: left;
  font-size: 0.875rem;
  margin-bottom: 30px;
}

.section-label {
  font-size: 0.69rem;
  color: #9e99a6;
  letter-spacing: 0.09em;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
}

.section-label button {
  background: transparent;
  font-size: 1.3rem;
  color: #aaa;
}

.channel {
  width: 100%;
  padding: 12px 10px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  display: flex;
  gap: 10px;
  font-size: 0.875rem;
  margin: 5px 0;
  overflow-wrap: anywhere;
}

.channel.selected {
  background: #39202b;
  color: #ffc1d0;
}

/* Показываю состояние соединения рядом с профилем. */
.connection {
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px;
  font-size: 0.8rem;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #76717d;
  flex-shrink: 0;
}

.status-dot.active {
  background: var(--accent);
  box-shadow: 0 0 12px #e83961;
}

.connection small {
  font-size: 0.73rem;
}

.profile {
  background: #141418;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 17px 13px;
  font-size: 0.8rem;
}

.profile > div:nth-child(2) {
  min-width: 0;
  overflow-wrap: anywhere;
}

.profile small {
  font-size: 0.7rem;
}

/* Задаю общую форму аватара и выравниваю содержимое по центру. */
.avatar {
  height: 36px;
  width: 36px;
  border-radius: 12px;
  background: #442534;
  color: #ffd0db;
  display: grid;
  place-items: center;
  font-weight: 700;
  flex-shrink: 0;
}

.icon-button {
  margin-left: auto;
  background: transparent;
  font-size: 1.4rem;
  color: var(--muted);
}

main {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: radial-gradient(ellipse at 70% 10%, #29192055, transparent 55%);
}

.room-header {
  height: 85px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 28px;
  gap: 14px;
}

.room-header > div {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.room-header strong {
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.hash {
  color: #ad7487;
  font-size: 1.4rem;
}

.pill {
  font-size: 0.65rem;
  padding: 5px 7px;
  border-radius: 5px;
  border: 1px solid #45313b;
  color: #d793a7;
}

.private-label {
  font-size: 0.75rem;
  color: #827b89;
}

/* Центрирую содержимое пустого состояния, пока пользователь не выбрал комнату. */
.empty {
  flex: 1;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 60px 24px;
}

.empty-art {
  width: 125px;
  height: 125px;
  display: grid;
  place-items: center;
  border: 1px solid #4a2735;
  border-radius: 38px;
  background: #26181f;
  transform: rotate(-9deg);
  margin-bottom: 35px;
  box-shadow: 0 0 90px #9c153020;
}

.empty-art img {
  width: 65px;
  transform: rotate(9deg);
}

.empty h2 {
  font-size: 2.2rem;
  letter-spacing: -0.045em;
  line-height: 1.2;
  margin: 20px 0;
}

.empty p {
  font-size: 0.95rem;
  margin-bottom: 30px;
}

.main-footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  padding: 20px 28px;
  font-size: 0.73rem;
  color: #6e6571;
  border-top: 1px solid #242127;
}

.main-footer > span:first-child {
  font-weight: 700;
  color: #a699a5;
}

/* Оформляю правую панель со списком участников. */
.members {
  background: #151519;
  border-left: 1px solid var(--line);
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
}

.members .section-label {
  padding-bottom: 28px;
}

.member {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  margin-bottom: 18px;
  overflow-wrap: anywhere;
}

.members-note {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 22px;
  font-size: 0.85rem;
  color: #706875;
  line-height: 1.8;
}

.members-note strong {
  font-weight: 400;
  color: #b3a4b3;
}

.room-view {
  padding: 34px 28px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.stage-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.stage-top h1 {
  font-size: 1.8rem;
  margin-top: 12px;
  overflow-wrap: anywhere;
}

.stage-top .muted {
  font-size: 0.8rem;
}

.prejoin {
  text-align: center;
  margin: auto;
  padding: 60px 15px;
}

.prejoin-symbol {
  font-size: 4rem;
  color: var(--accent);
  margin-bottom: 20px;
}

.prejoin .primary {
  margin: 30px auto 0;
}

/* Распределяю карточки участников по доступной ширине через auto-fit. */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  align-content: start;
}

.tile {
  position: relative;
  aspect-ratio: 16/11;
  overflow: hidden;
  border-radius: 13px;
  background: linear-gradient(135deg, #35222e, #201c25);
  border: 2px solid transparent;
  display: grid;
  place-items: center;
}

.tile.speaking {
  border-color: var(--accent);
  box-shadow: 0 0 25px #e8396122;
}

.tile.video video {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Отвожу демонстрации всю ширину сетки и сохраняю пропорции 16:9. */
.tile.screen {
  grid-column: 1/-1;
  aspect-ratio: 16/9;
  background: #08090a;
}

.tile.screen video {
  object-fit: contain;
}

.tile .initial {
  font-size: 3rem;
  color: #e5acbd;
}

/* Ограничиваю длинное имя шириной карточки, чтобы оно не выходило за её края. */
.tile .tile-label {
  position: absolute;
  bottom: 12px;
  left: 12px;
  padding: 5px 9px;
  background: #101014cc;
  border-radius: 5px;
  font-size: 0.8rem;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Размещаю кнопки звонка рядом и разрешаю перенос на узком экране. */
.call-controls {
  margin: 25px auto 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  padding: 10px;
  border-radius: 13px;
  background: #1b1a20;
  border: 1px solid var(--line);
}

.call-controls button {
  padding: 13px 15px;
  border-radius: 8px;
  background: #302b35;
  font-size: 0.8rem;
}

.call-controls button[aria-pressed='true'] {
  background: #62253c;
  color: #ffd1de;
}

.call-controls .danger {
  background: #cb2a4f;
}

.call-controls #audio {
  background: #70561c;
}

/* Задаю общий вид диалоговых окон и затемнение под ними. */
dialog {
  background: #1c1b21;
  color: var(--text);
  border: 1px solid #49404b;
  border-radius: 16px;
  padding: 36px;
  width: min(440px, 90vw);
}

dialog::backdrop {
  background: #000a;
  backdrop-filter: blur(5px);
}

dialog h2 {
  margin-top: 15px;
}

dialog .primary {
  width: 100%;
}

dialog .close {
  position: absolute;
  right: 15px;
  top: 12px;
  background: transparent;
  font-size: 1.6rem;
  color: var(--muted);
}

#toast {
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  border: 1px solid #784155;
  background: #38222d;
  padding: 15px 24px;
  border-radius: 10px;
  z-index: 10;
  font-size: 0.875rem;
  max-width: 90vw;
}

/* Сохраняю действие атрибута hidden даже у элементов с display: flex или grid. */
[hidden] {
  display: none !important;
}

/* На широком экране увеличиваю место для боковых панелей. */
@media (min-width: 1600px) {
  .workspace {
    grid-template-columns: 88px 270px minmax(0, 1fr) 260px;
  }
}

/* Подстраиваю расположение и размеры элементов под указанную ширину экрана. */
@media (max-width: 1200px) {
  .members {
    display: none;
  }

  .workspace {
    grid-template-columns: 72px 230px minmax(0, 1fr);
  }

  .private-label {
    display: none;
  }
}

/* Подстраиваю расположение и размеры элементов под указанную ширину экрана. */
@media (max-width: 760px) {
  .auth {
    display: block;
  }

  .identity {
    min-height: auto;
    padding: 22px;
  }

  .identity-copy,
  .identity footer,
  .soundwave {
    display: none;
  }

  .auth-pane {
    padding: 45px 24px 85px;
    min-height: calc(100dvh - 87px);
  }

  .workspace {
    grid-template-columns: 60px minmax(0, 1fr);
  }

  .rail {
    grid-row: 1/3;
    padding: 16px 5px;
  }

  .rail-logo,
  .server-icon {
    width: 42px;
    height: 42px;
  }

  .sidebar {
    grid-column: 2;
  }

  .sidebar header {
    min-height: 60px;
    padding: 15px;
  }

  .sidebar-body {
    padding: 12px;
  }

  .sidebar .section-label {
    margin: 5px 0;
  }

  #channels {
    display: flex;
    flex-wrap: wrap;
  }

  .channel {
    width: auto;
  }

  .invite {
    margin-bottom: 10px;
  }

  .connection,
  .profile {
    padding: 10px 14px;
  }

  .profile {
    position: relative;
  }

  .sidebar-body #sidebar-empty {
    margin: 5px;
  }

  .workspace main {
    grid-column: 2;
    min-height: 65dvh;
  }

  .room-header {
    height: auto;
    padding: 16px;
  }

  .room-header .pill {
    display: none;
  }

  .empty {
    padding: 35px 20px;
  }

  .empty h2 {
    font-size: 1.7rem;
  }

  .empty-art {
    height: 85px;
    width: 85px;
    border-radius: 25px;
  }

  .empty-art img {
    width: 50px;
  }

  .room-view {
    padding: 22px 14px;
  }

  .stage-top {
    align-items: flex-start;
    flex-direction: column;
    gap: 0;
  }

  .tiles {
    grid-template-columns: 1fr;
  }

  .call-controls {
    gap: 6px;
  }

  .call-controls button {
    padding: 12px;
  }

  .main-footer {
    padding: 18px 14px;
    gap: 15px;
  }

  .main-footer span:last-child {
    display: none;
  }
}

/* Учитываю системную настройку уменьшения движения. */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

.tile .tile-label {
  z-index: 2;
  pointer-events: none;
}
