/* ============================================================
   WALL — база: обвязка, каркас, сетка, плитки, чат
   ============================================================ */

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

html, body {
  margin: 0;
  height: 100%;
  background: #05060a;
  color: #fff;
  font-family: -apple-system, "Segoe UI Variable", "Segoe UI", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.spacer { flex: 1; }

.ic {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ================= демо-обвязка ================= */

.showcase {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 12px;
  background:
    radial-gradient(110% 70% at 50% -10%, #151a2b 0%, #06070c 55%, #040509 100%);
}

.frame {
  flex: 1;
  min-height: 0;
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #232a3d;
  background: #000;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .65), 0 0 0 1px rgba(255, 255, 255, .02) inset;
}

body.fs .showcase { padding: 0; gap: 0; }
body.fs .frame { border-radius: 0; border: 0; }

/* ================= каркас приложения ================= */

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  overflow: hidden;
  position: relative;
}

/* ---------- топбар ---------- */

.topbar {
  flex: none;
  height: var(--top);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: relative;
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 9px; }

.logo {
  width: 24px;
  height: 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  padding: 2px;
  border-radius: 7px;
  background: var(--accent-soft);
}
.logo i { background: var(--accent); border-radius: 1.5px; opacity: .45; }
.logo i:first-child { opacity: 1; }

.brand-txt { display: flex; align-items: baseline; gap: 7px; }
.brand-txt b { font-size: 14px; letter-spacing: .12em; }
.brand-txt em { font-style: normal; font-size: 10.5px; color: var(--faint); letter-spacing: .04em; }

.seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.seg-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--dim);
  font-size: 12px;
  white-space: nowrap;
}
.seg-btn .ic { width: 14px; height: 14px; }
.seg-btn:hover { color: var(--text); }
.seg-btn.on { background: var(--bg); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .4); }

.filters { display: flex; gap: 4px; }

.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--dim);
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 12px;
  white-space: nowrap;
}
.chip em {
  font-style: normal;
  font-size: 10px;
  color: var(--dim);
  background: var(--panel-2);
  border-radius: 4px;
  padding: 1px 4px;
}
.chip:hover { color: var(--text); }
.chip.on { background: var(--accent-soft); color: var(--accent); }
.chip.on em { color: var(--accent); background: rgba(255, 255, 255, .06); }

.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.search {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 210px;
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--faint);
}
.search .ic { width: 14px; height: 14px; }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 12px;
  color: var(--text);
}
.search input::placeholder { color: var(--faint); }
.search:focus-within { border-color: var(--accent); color: var(--accent); }

.live-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--dim);
  white-space: nowrap;
}
.live-pill b { color: var(--text); font-variant-numeric: tabular-nums; }

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 3px rgba(255, 77, 97, .15);
  flex: none;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #0a0a0f;
  font-weight: 800;
  font-size: 12px;
}

/* ---------- рабочая область ---------- */

.workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
}

.stage {
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: var(--pad);
  position: relative;
}

/* ---------- умная сетка ---------- */

.grid {
  --cols: 4;
  --rows: 4;
  height: 100%;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: var(--gap);
}

.grid .tile {
  width: calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols));
  height: calc((100% - (var(--rows) - 1) * var(--gap)) / var(--rows));
}

/* ---------- плитка стрима ---------- */

.tile {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: #0b0e15;
  cursor: pointer;
  isolation: isolate;
  transition: box-shadow .16s ease, transform .16s ease;
  /* цвет рамки зависит от площадки: Twitch — фиолетовый, Kick — зелёный */
  --plat: var(--accent);
  --plat-ring: rgba(55, 224, 138, .45);
  --plat-glow: rgba(55, 224, 138, .35);
  --plat-soft: rgba(55, 224, 138, .2);
  --plat-line: rgba(55, 224, 138, .45);
}

.is-twitch {
  --plat: #a970ff;
  --plat-ring: rgba(169, 112, 255, .6);
  --plat-glow: rgba(169, 112, 255, .45);
  --plat-soft: rgba(169, 112, 255, .2);
  --plat-line: rgba(169, 112, 255, .5);
}

.is-kick {
  --plat: #37e08a;
  --plat-ring: rgba(55, 224, 138, .5);
  --plat-glow: rgba(55, 224, 138, .35);
  --plat-soft: rgba(55, 224, 138, .18);
  --plat-line: rgba(55, 224, 138, .45);
}

.tile.is-hidden { display: none; }

.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 6;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .07);
  pointer-events: none;
  transition: box-shadow .16s ease;
}
.tile:hover::after { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2); }
.tile.is-selected::after { box-shadow: inset 0 0 0 1px var(--plat); }
.tile.is-selected { box-shadow: 0 0 34px -10px var(--plat-glow); }

.scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #0a0d14;
  container-type: size;
}

.scene::before {
  content: "";
  position: absolute;
  inset: -12%;
  pointer-events: none;
  background:
    radial-gradient(46% 56% at 26% 28%, var(--c1) 0%, transparent 70%),
    radial-gradient(52% 62% at 80% 82%, var(--c2) 0%, transparent 72%),
    linear-gradient(155deg, #171c29 0%, #07090f 72%);
  opacity: .95;
}

.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  /* затемнение не должно перехватывать клики: под ним живёт плеер */
  pointer-events: none;
  background: linear-gradient(180deg, rgba(5, 6, 10, .02) 30%, rgba(5, 6, 10, .62) 100%);
}

/* в сетке нижней плашки с именем больше нет: кадр не нужно затемнять
   к низу, лёгкая виньетка остаётся только под панелью плеера */
.grid .scene::after {
  background: linear-gradient(180deg, transparent 72%, rgba(5, 6, 10, .32) 100%);
}

.mono-letter {
  position: absolute;
  right: -2%;
  bottom: -16%;
  z-index: 1;
  font-size: clamp(34px, 9vw, 140px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.06em;
  color: #fff;
  opacity: .07;
  user-select: none;
}
@supports (container-type: size) {
  .mono-letter { font-size: 46cqw; }
}

/* верхняя плашка плитки: имя и категория слева, статус и избранное справа */
.t-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  background: linear-gradient(180deg, rgba(3, 4, 8, .62), transparent);
}

.t-id {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.t-id .t-txt { min-width: 0; }

.t-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}

/* живой канал: спокойная точка вместо красной плашки LIVE */
.badge-live {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 3px rgba(255, 77, 97, .14);
}

.badge-plat {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .03em;
  padding: 2px 5px;
  border-radius: 3px;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(6px);
  color: #c9c2ff;
}
.badge-plat.kick { color: #a9f7a0; }

/* кнопка «в избранное»: единственная кнопка в правом верхнем углу плитки */
.t-btn {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(10, 12, 18, .66);
  backdrop-filter: blur(8px);
  color: #d7dbe6;
  padding: 0;
}
.t-btn .ic { width: 13px; height: 13px; }
.t-btn:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.t-btn.on { color: var(--accent); border-color: var(--accent); }

.t-fav { width: 22px; height: 22px; border-radius: 50%; }
.t-fav.on {
  color: #ffce5c;
  border-color: rgba(255, 206, 92, .45);
  background: rgba(42, 33, 10, .6);
}
.t-fav.on .ic { fill: currentColor; stroke: none; }

.t-ava {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  color: #0b0b10;
  background: var(--ac);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .18);
}

.t-txt { min-width: 0; flex: 1; }
.t-name {
  font-size: 12px;
  font-weight: 650;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.t-game {
  font-size: 10.5px;
  color: rgba(230, 235, 245, .58);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.t-viewers {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  color: rgba(230, 235, 245, .72);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.t-viewers .ic { width: 11px; height: 11px; opacity: .7; }

/* в тесной сетке 4×4 и плотнее счётчик зрителей уступает место имени:
   иначе «welovegames» и категория обрезаются до пары букв */
.grid[data-cols="4"] .t-viewers,
.grid[data-cols="5"] .t-viewers,
.grid[data-cols="6"] .t-viewers { display: none; }

/* офлайн */
.tile.is-offline { cursor: pointer; }
.tile.is-offline .scene { filter: grayscale(1) brightness(.42); }
.tile.is-offline .t-top { opacity: .55; }

.offline-tag {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(235, 240, 250, .55);
}
.offline-tag span {
  display: block;
  font-size: 9.5px;
  font-weight: 400;
  letter-spacing: .02em;
  text-transform: none;
  /* .32 на тёмном кадре давало контраст ~2.7:1 — подпись не читалась */
  color: rgba(235, 240, 250, .55);
}

/* ---------- пустое состояние ---------- */

.empty {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  place-content: center;
  justify-items: center;
  text-align: center;
  gap: 6px;
  padding: 24px;
  background: var(--bg);
}
.app.is-empty .empty { display: grid; }

.empty-ic {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--dim);
  margin-bottom: 4px;
}
.empty-ic .ic { width: 22px; height: 22px; }
.empty b { font-size: 16px; }
.empty p { margin: 0 0 8px; color: var(--dim); font-size: 12.5px; max-width: 280px; line-height: 1.5; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 12px;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ================= чат ================= */

.chat {
  width: var(--chatw);
  flex: none;
  min-height: 0;
  display: none;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--line);
}
.app.chat-open .chat { display: flex; }

.chat-head {
  flex: none;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 12px;
  border-bottom: 1px solid var(--line);
}

.ch-id { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; }

.ch-ava {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  color: #0b0b10;
  background: var(--accent);
}

.ch-meta { min-width: 0; }
.ch-name { font-size: 13px; font-weight: 700; line-height: 1.25; }
.ch-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  color: var(--dim);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ch-sub .dot { width: 5px; height: 5px; box-shadow: none; }

.ch-actions { display: flex; gap: 2px; }

.icon-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--dim);
  padding: 0;
}
.icon-btn .ic { width: 15px; height: 15px; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.on { color: #ffce5c; }
.icon-btn.on .ic { fill: currentColor; stroke: none; }

.chat-pin {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 10.5px;
  color: var(--dim);
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-pin .ic { width: 12px; height: 12px; color: var(--accent); }

.chat-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.chat-body::-webkit-scrollbar { width: 8px; }
.chat-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* ---------- реальные эмбеды ---------- */

.tile .embed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #000;
}

.tile.is-live .scene::after {
  background: linear-gradient(180deg, rgba(5, 6, 10, 0) 58%, rgba(5, 6, 10, .5) 100%);
}

.player {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #000;
}
.player iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.chat-body.is-embed {
  padding: 0;
  display: block;
  overflow: hidden;
  background: #0e0e10;
}
.chat-body.is-embed iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.chat-off {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--dim);
  padding: 14px 2px;
}
.chat-off b { color: var(--text); }

.msg {
  font-size: 12.5px;
  line-height: 1.45;
  color: #c3cad8;
  word-wrap: break-word;
  animation: msgIn .18s ease;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(3px); } }
.msg b { font-weight: 700; margin-right: 4px; }
.msg .m-txt { color: #c3cad8; }

.m-badge {
  display: inline-block;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .05em;
  padding: 1px 3px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: 1px;
}
.m-badge.mod { background: #2f7d4f; color: #b9ffd6; }
.m-badge.sub { background: #5a3f8f; color: #e2d4ff; }

.emote {
  display: inline-block;
  padding: 0 4px;
  border-radius: 3px;
  background: var(--panel-2);
  font-size: 11px;
  color: #e9d9ff;
}

.chat-channels { display: none; flex: 1; min-height: 0; overflow-y: auto; padding: 6px; }
.app[data-variant="c"] .chat-channels { display: none; }
.app.tab-channels .chat-body,
.app.tab-channels .chat-pin { display: none; }
.app.tab-channels .chat-channels { display: block; }

.chat-tabs { display: none; flex: none; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--line); }
.chat-tabs button {
  border: 0;
  background: transparent;
  color: var(--dim);
  font-size: 11.5px;
  padding: 8px 10px;
  border-bottom: 2px solid transparent;
}
.chat-tabs button em {
  font-style: normal;
  font-size: 9.5px;
  color: var(--faint);
  margin-left: 3px;
}
.chat-tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

.ch-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  text-align: left;
  color: var(--text);
}
.ch-row:hover { background: var(--panel-2); }
.ch-row.on { background: var(--accent-soft); }
.ch-row-ava {
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 800;
  color: #0b0b10;
  background: var(--ac);
}

/* настоящие аватарки каналов: картинка из Twitch/Kick, буква остаётся запасной */
.t-ava.has-img,
.ch-ava.has-img,
.ch-row-ava.has-img,
.tb-ava.has-img,
.quad-ava.has-img {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.ch-row-txt { flex: 1; min-width: 0; }
.ch-row-txt b { display: block; font-size: 11.5px; font-weight: 650; line-height: 1.3; }
.ch-row-txt i { display: block; font-style: normal; font-size: 10px; color: var(--faint); }
.ch-row-r { display: flex; align-items: center; gap: 5px; font-size: 10px; color: var(--dim); }
.ch-row-r .dot { width: 5px; height: 5px; box-shadow: none; }
.ch-row-r .off { color: var(--faint); }

.chat-form {
  flex: none;
  display: flex;
  gap: 6px;
  padding: 9px 10px;
  border-top: 1px solid var(--line);
}
.chat-form input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 12px;
  outline: none;
}
.chat-form input::placeholder { color: var(--faint); }
.chat-form input:focus { border-color: var(--accent); }

.send {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #08090d;
  padding: 0;
}
.send .ic { width: 15px; height: 15px; stroke-width: 2; }
.send:hover { filter: brightness(1.1); }

/* ================= тост ================= */

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(18px + var(--status));
  transform: translate(-50%, 12px);
  z-index: 80;
  padding: 8px 14px;
  border-radius: 9px;
  background: rgba(14, 17, 26, .94);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .5);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ================= статусбар ================= */

.statusbar {
  flex: none;
  height: 30px;
  display: none;
  align-items: center;
  gap: 16px;
  padding: 0 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  color: var(--dim);
  font-size: 10.5px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
}
.statusbar b { color: var(--text); font-weight: 600; }
