/* ============================================================
   ExMeeting — UI прототип
   Дизайн система (светла тема по подразбиране)
   ============================================================ */

:root {
  /* Повърхности */
  --bg:            #f3f4f7;
  --bg-2:          #ffffff;
  --surface:       #ffffff;
  --surface-2:     #f1f2f6;
  --surface-3:     #e5e7ee;
  --tile:          #1b1c22;        /* видео плочките остават тъмни */
  --border:        rgba(16, 18, 27, .10);
  --border-strong: rgba(16, 18, 27, .18);

  /* Текст */
  --text:          #14161c;
  --text-2:        #5b606e;
  --text-3:        #8b909f;

  /* Акценти */
  --accent:        #2f6fed;
  --accent-soft:   rgba(47, 111, 237, .12);
  --danger:        #d92d3a;
  --danger-hover:  #ea3b48;
  --success:       #3cb44b;        /* зеленото от логото */
  --warn:          #d98514;

  /* Контроли */
  --ctl-bg:        #e8eaf1;
  --ctl-bg-hover:  #dcdfe9;
  --ctl-off-bg:    #23252e;        /* изключен микрофон/камера */
  --ctl-off-fg:    #ffffff;

  /* Форма */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-full: 999px;

  --shadow-1: 0 2px 6px rgba(16, 18, 27, .10);
  --shadow-2: 0 10px 28px rgba(16, 18, 27, .12);
  --shadow-3: 0 22px 56px rgba(16, 18, 27, .16);

  --ctl: 52px;          /* размер на кръглите контроли */
  --ease: cubic-bezier(.32, .72, 0, 1);

  /* --- Стъкло (Liquid Glass) ---
     Прозрачен слой + размиване на фона + светъл ръб отгоре.
     Слоят стои НАД съдържанието, а не на собствен непрозрачен фон.        */
  --glass:          rgba(255, 255, 255, .62);
  --glass-strong:   rgba(255, 255, 255, .78);
  --glass-border:   rgba(255, 255, 255, .55);
  --glass-edge:     rgba(16, 18, 27, .10);
  --glass-hi:       rgba(255, 255, 255, .85);
  --glass-blur:     saturate(180%) blur(22px);
  --glass-shadow:   0 10px 34px rgba(16, 18, 27, .14), 0 2px 8px rgba(16, 18, 27, .08);

  /* Меки цветни петна за фона — стъклото има какво да пречупва */
  --mesh-1: rgba(47, 111, 237, .16);
  --mesh-2: rgba(60, 180, 75, .14);
  --mesh-3: rgba(255, 138, 76, .10);
}

/* Тъмна тема — по желание, от менюто „Още" */
:root[data-theme="dark"] {
  --bg: #0a0a0c; --bg-2: #101014; --surface: #16161b; --surface-2: #1d1d23;
  --surface-3: #26262e; --tile: #14141a;
  --border: rgba(255,255,255,.08); --border-strong: rgba(255,255,255,.16);
  --text: #f4f4f6; --text-2: #a1a1ad; --text-3: #6d6d79;
  --accent: #4d8dff; --accent-soft: rgba(77,141,255,.16);
  --danger: #e5484d; --danger-hover: #f0595e;
  --ctl-bg: #26262e; --ctl-bg-hover: #33333d;
  --ctl-off-bg: #f1f2f5; --ctl-off-fg: #15151a;
  --shadow-1: 0 2px 8px rgba(0,0,0,.35);
  --shadow-2: 0 12px 32px rgba(0,0,0,.45);
  --shadow-3: 0 24px 64px rgba(0,0,0,.55);

  --glass:        rgba(30, 32, 40, .58);
  --glass-strong: rgba(30, 32, 40, .78);
  --glass-border: rgba(255, 255, 255, .14);
  --glass-edge:   rgba(0, 0, 0, .5);
  --glass-hi:     rgba(255, 255, 255, .22);
  --glass-shadow: 0 10px 34px rgba(0, 0, 0, .45), 0 2px 8px rgba(0, 0, 0, .3);

  --mesh-1: rgba(77, 141, 255, .22);
  --mesh-2: rgba(62, 207, 142, .14);
  --mesh-3: rgba(255, 138, 76, .10);
}

/* ============================================================
   Стъкленият материал
   ============================================================ */

.glass,
.topbar,
.controls-center, .controls-left, .controls-right,
.reactions, .menu, .toast,
.panel, .modal-card,
.prejoin, .ended-card, .brand-hero {
  position: relative;
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}
/* специкуларният ръб — светъл отгоре, който гасне надолу */
.glass::after,
.topbar::after,
.controls-center::after, .controls-left::after, .controls-right::after,
.reactions::after, .menu::after, .toast::after,
.panel::after, .modal-card::after,
.prejoin::after, .ended-card::after, .brand-hero::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(to bottom, var(--glass-hi), transparent 42%);
  opacity: .5; mix-blend-mode: overlay;
}

/* Панелите и диалозите носят текст — стъклото им е по-плътно, за да се чете */
.panel, .modal-card, .menu, .toast, .prejoin, .ended-card {
  background: var(--glass-strong);
}

/* Когато браузърът няма backdrop-filter или човекът е намалил прозрачността,
   слоят става плътен — четимостта е по-важна от ефекта. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass, .topbar, .controls-center, .controls-left, .controls-right,
  .reactions, .menu, .toast, .panel, .modal-card, .prejoin, .ended-card, .brand-hero {
    background: var(--bg-2);
  }
  .glass::after, .topbar::after, .controls-center::after, .controls-left::after,
  .controls-right::after, .reactions::after, .menu::after, .toast::after,
  .panel::after, .modal-card::after, .prejoin::after, .ended-card::after,
  .brand-hero::after { display: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .glass, .topbar, .controls-center, .controls-left, .controls-right,
  .reactions, .menu, .toast, .panel, .modal-card, .prejoin, .ended-card, .brand-hero {
    background: var(--bg-2);
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .glass::after, .topbar::after, .controls-center::after, .controls-left::after,
  .controls-right::after, .reactions::after, .menu::after, .toast::after,
  .panel::after, .modal-card::after, .prejoin::after, .ended-card::after,
  .brand-hero::after { display: none; }
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
::selection { background: var(--accent-soft); }

svg { display: block; }
.icon { width: 21px; height: 21px; stroke: currentColor; fill: none;
        stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
.icon-xs { width: 13px; height: 13px; }

/* Скролбари */
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: var(--r-full); }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ============================================================
   Бутони
   ============================================================ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 20px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-weight: 550; font-size: 14px;
  transition: background .18s var(--ease), transform .18s var(--ease), border-color .18s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn-primary:hover { background: #5d98ff; }
.btn-danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-lg { height: 52px; padding: 0 28px; font-size: 15px; }
.btn-block { width: 100%; }

/* Кръгла контрола (лентата долу) */
.ctl {
  position: relative;
  width: var(--ctl); height: var(--ctl);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-full);
  background: var(--ctl-bg);
  color: var(--text);
  transition: background .18s var(--ease), transform .16s var(--ease), color .18s;
}
.ctl:hover { background: var(--ctl-bg-hover); }
.ctl:active { transform: scale(.93); }
.ctl:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.ctl.is-off { background: var(--ctl-off-bg); color: var(--ctl-off-fg); }   /* изключено */
.ctl.is-on  { background: var(--accent); color: #fff; }
.ctl.is-end { background: var(--danger); color: #fff; width: 62px; border-radius: var(--r-full); }
.ctl.is-end:hover { background: var(--danger-hover); }

[hidden] { display: none !important; }

.ctl .badge {
  position: absolute; top: -2px; right: -2px;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-full);
  background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1;
  border: 2px solid var(--bg);
}

/* Подсказка */
.tip { position: relative; }
.tip::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 10px); left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 6px 10px; border-radius: 8px;
  background: #000; color: #fff; font-size: 12px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s;
  box-shadow: var(--shadow-1); z-index: 60;
}
.tip:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (max-width: 860px) { .tip::after { display: none; } }

/* ============================================================
   Начален екран (index.html)
   ============================================================ */

.lobby {
  height: 100dvh; overflow-y: auto; overflow-x: hidden;
  background:
    radial-gradient(820px 560px at 10% -8%, var(--mesh-1), transparent 62%),
    radial-gradient(720px 520px at 92% 6%, var(--mesh-3), transparent 58%),
    radial-gradient(900px 620px at 60% 104%, var(--mesh-2), transparent 60%),
    var(--bg);
}
.lobby-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px clamp(20px, 5vw, 56px);
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; letter-spacing: -.02em; font-size: 17px; }
/* Марката на сайта — иконата има собствена стъклена плочка */
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; overflow: hidden;
  display: grid; place-items: center; flex: none;
  box-shadow: var(--shadow-1);
}
.brand-mark img { width: 100%; height: 100%; display: block; object-fit: contain; }

/* Светъл и тъмен вариант на иконата */
:root:not([data-theme="dark"]) .only-dark { display: none; }
:root[data-theme="dark"] .only-light { display: none; }
:root[data-theme="dark"] .only-dark { display: block; }
.brand-name { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name small {
  font-size: 10px; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-3);
}

/* Голямото лого на началния екран */
.brand-hero {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-lg); padding: 14px; margin-bottom: 26px;
}
.brand-hero img { width: 96px; height: auto; display: block; }

.lobby-main {
  display: grid; grid-template-columns: 1.05fr 1fr; gap: clamp(28px, 5vw, 72px);
  align-items: center;
  min-height: calc(100dvh - 160px);
  max-width: 1180px; margin: 0 auto; width: 100%;
  padding: clamp(16px, 3vh, 40px) clamp(20px, 5vw, 56px) 56px;
}
.lobby-main > * { min-width: 0; }   /* колоните да могат да се свиват под телефон */

.lobby-copy h1 {
  margin: 0 0 16px;
  font-size: clamp(34px, 5vw, 54px); line-height: 1.06;
  letter-spacing: -.035em; font-weight: 700;
}
.lobby-copy h1 em { font-style: normal; color: var(--accent); }
.lobby-copy p.lead { margin: 0 0 30px; color: var(--text-2); font-size: 17px; max-width: 46ch; }

.join-row { display: flex; gap: 10px; margin-bottom: 26px; }
.join-row .btn { flex: none; }
.field {
  display: flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 18px; flex: 1 1 140px; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-full);
  transition: border-color .18s, background .18s;
}
.field:focus-within { border-color: var(--accent); background: var(--surface-2); }
.field input { flex: 1; min-width: 0; background: none; border: 0; outline: none; font-size: 15px; }
.field input::placeholder { color: var(--text-3); }
.field .icon { color: var(--text-3); flex: none; }

.join-hint { margin: -10px 0 24px; font-size: 13px; color: var(--text-2); max-width: 48ch; }
.join-hint b { color: var(--text); }

.feature-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.feature-list li { display: flex; align-items: center; gap: 11px; color: var(--text-2); font-size: 14.5px; }
.feature-list .dot {
  width: 24px; height: 24px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}

/* Preview карта */
.prejoin {
  border-radius: var(--r-xl); padding: 16px;
}
.prejoin-stage {
  position: relative; aspect-ratio: 4 / 3; border-radius: var(--r-lg);
  overflow: hidden; background: var(--tile);
}
.prejoin-stage video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.prejoin-stage .placeholder {
  position: absolute; inset: 0; display: grid; place-items: center; gap: 12px;
  align-content: center; text-align: center; color: var(--text-3); padding: 24px;
}
.prejoin-stage .placeholder .avatar { width: 88px; height: 88px; font-size: 30px; }
.prejoin-stage .placeholder p { margin: 0; font-size: 13px; max-width: 30ch; }
.prejoin-stage.has-video .placeholder { display: none; }

.prejoin-overlay {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 14px;
  display: flex; justify-content: center; gap: 10px;
  background: linear-gradient(to top, rgba(0,0,0,.6), transparent);
}
.prejoin-overlay .ctl { width: 46px; height: 46px; background: rgba(20,20,26,.72); backdrop-filter: blur(10px); }
.prejoin-overlay .ctl.is-off { background: #f1f2f5; color: #15151a; }
.prejoin-stage .placeholder .avatar { background: linear-gradient(140deg, var(--accent), #6f5bff); }

.prejoin-foot { display: flex; gap: 10px; margin-top: 14px; align-items: center; }
.prejoin-foot .field { height: 48px; }

/* ============================================================
   Стая (room.html)
   ============================================================ */

/* Съдържанието е едно цяло платно; лентите плуват над него като стъкло. */
.room {
  position: relative; height: 100dvh; overflow: hidden;
  background:
    radial-gradient(760px 520px at 8% 0%, var(--mesh-1), transparent 62%),
    radial-gradient(680px 480px at 96% 8%, var(--mesh-2), transparent 58%),
    radial-gradient(700px 520px at 50% 108%, var(--mesh-3), transparent 60%),
    var(--bg);
}

/* --- Горна лента (плаващо стъкло) --- */
.topbar {
  position: absolute; z-index: 30;
  top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 12px; padding: 8px 10px;
  border-radius: var(--r-lg);
}
.topbar-side { display: flex; align-items: center; gap: 8px; }
.topbar-side.right { justify-content: flex-end; }
.topbar .ctl { width: 40px; height: 40px; background: var(--glass-strong); }
.topbar .ctl:hover { background: var(--ctl-bg-hover); }
.topbar .brand { margin-right: 6px; }
.topbar .brand-mark { width: 36px; height: 36px; border-radius: 11px; }
.topbar .ctl.is-active { background: var(--accent-soft); color: var(--accent); }

/* Логото и името на конкретната стая — до заглавието, не вместо марката */
.room-badge {
  display: inline-flex; align-items: center; gap: 8px;
  min-width: 0; justify-content: center;
}
.room-badge img {
  width: 22px; height: 22px; border-radius: 7px; flex: none;
  object-fit: contain; background: #fff; padding: 2px;
  border: 1px solid var(--glass-edge);
}
.room-badge img[hidden] { display: none; }

.meeting-meta { text-align: center; min-width: 0; }
.meeting-meta h1 {
  margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.meeting-sub {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  color: var(--text-2); font-size: 12.5px; margin-top: 2px;
}
.rec-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--danger); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.meeting-sub .sep { color: var(--text-3); }

/* --- Сцена (заема целия екран; лентите минават отгоре) --- */
.stage-wrap {
  position: absolute; inset: 0;
  display: flex; min-height: 0; min-width: 0; gap: 12px;
  padding: calc(76px + env(safe-area-inset-top)) clamp(12px, 2vw, 20px)
           calc(96px + env(safe-area-inset-bottom));
  overflow: hidden;
}
.stage { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 12px; }

.grid {
  flex: 1; min-height: 0;
  display: grid; gap: 12px;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows, 2), minmax(0, 1fr));
  align-content: stretch;
}

/* Speaker focus */
.speaker-view { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.speaker-main { flex: 1; min-height: 0; min-width: 0; }
.speaker-main .avatar { max-width: 132px; font-size: clamp(22px, 3vw, 38px); }
.speaker-main .tile-name { font-size: 13px; padding: 5px 11px; }
.filmstrip {
  display: flex; gap: 10px; overflow-x: auto; overflow-y: hidden;
  padding-bottom: 2px; scrollbar-width: thin; flex: none; min-width: 0; max-width: 100%;
}
.filmstrip .tile { width: 158px; flex: none; aspect-ratio: 4/3; }
.filmstrip .tile .tile-name { font-size: 11px; padding: 3px 7px; }
.filmstrip .tile .tile-name .icon { width: 11px; height: 11px; }

/* --- Плочка на участник --- */
.tile {
  position: relative; overflow: hidden; min-height: 0;
  border-radius: var(--r-md);
  background: var(--tile);
  border: 2px solid transparent;
  transition: border-color .2s var(--ease), transform .2s var(--ease);
}
.tile video { width: 100%; height: 100%; object-fit: cover; }
.tile.is-self video { transform: scaleX(-1); }
.tile.is-speaking { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(77,141,255,.14); }
.tile.is-pinned { border-color: rgba(255,255,255,.35); }

.tile-media { position: absolute; inset: 0; }
.tile-media img { width: 100%; height: 100%; object-fit: cover; }

/* Заместител, когато камерата е изключена */
.tile-fallback {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: #12121a; isolation: isolate;
}
.tile-fallback::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: var(--grad, linear-gradient(140deg, #2b2b35, #1a1a22));
  opacity: .22;
}
.avatar {
  width: 25%; min-width: 46px; max-width: 92px; aspect-ratio: 1;
  border-radius: 50%; display: grid; place-items: center;
  background: var(--grad, linear-gradient(140deg, #3a3a46, #22222c));
  color: #fff; font-weight: 600; letter-spacing: .02em;
  font-size: clamp(15px, 2.2vw, 26px);
  box-shadow: 0 8px 24px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.18);
}

.tile-name {
  position: absolute; left: 8px; bottom: 8px; z-index: 2;
  display: flex; align-items: center; gap: 6px;
  max-width: calc(100% - 16px);
  padding: 4px 9px; border-radius: var(--r-full);
  background: rgba(10,10,14,.62); backdrop-filter: blur(12px);
  color: #fff;                      /* плочките са тъмни и в светла тема */
  font-size: 12px; font-weight: 500; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile-name .icon { width: 13px; height: 13px; flex: none; }
.tile-name .muted { color: var(--danger); }

.tile-badges { position: absolute; top: 8px; left: 8px; z-index: 2; display: flex; gap: 6px; }
.tile-badge {
  width: 26px; height: 26px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent); color: #fff; box-shadow: var(--shadow-1);
}
.tile-badge.emoji { background: rgba(10,10,14,.7); backdrop-filter: blur(12px); font-size: 14px; }
.tile-badge .icon { width: 15px; height: 15px; }

.tile-actions { position: absolute; top: 8px; right: 8px; z-index: 3; opacity: 0; transition: opacity .18s; }
.tile:hover .tile-actions { opacity: 1; }
.tile-actions button {
  width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
  background: rgba(10,10,14,.7); backdrop-filter: blur(12px); color: #fff;
}
.tile-actions button:hover { background: rgba(10,10,14,.92); }

.tile.is-screen .tile-media { background: #08080b; }
.tile.is-screen .tile-media img { object-fit: contain; }

/* --- Лента с контроли (плаващо стъкло) --- */
.controls {
  position: absolute; z-index: 30;
  left: 0; right: 0; bottom: max(16px, env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 0 clamp(12px, 2vw, 20px);
  pointer-events: none;
}
.controls > * { pointer-events: auto; }
.controls-left, .controls-right {
  display: flex; gap: 8px; padding: 7px;
  border-radius: var(--r-full);
}
.controls-center {
  display: flex; gap: 10px; padding: 8px;
  border-radius: var(--r-full);
}

/* Изскачащи реакции */
.reactions {
  position: absolute; bottom: calc(100% + 12px); left: 50%; transform: translateX(-50%) translateY(6px);
  display: flex; gap: 4px; padding: 8px;
  border-radius: var(--r-full);
  opacity: 0; pointer-events: none; transition: opacity .18s var(--ease), transform .18s var(--ease);
  z-index: 40;
}
.reactions.open { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.reactions button {
  width: 42px; height: 42px; border-radius: var(--r-full); font-size: 21px;
  display: grid; place-items: center; transition: background .15s, transform .15s var(--ease);
}
.reactions button:hover { background: var(--surface-3); transform: translateY(-3px) scale(1.12); }

/* Летящи емоджита */
.float-layer { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.float-emoji { position: absolute; font-size: 34px; animation: floatUp 2.6s var(--ease) forwards; }
@keyframes floatUp {
  0%   { transform: translateY(0) scale(.6); opacity: 0; }
  12%  { transform: translateY(-24px) scale(1.1); opacity: 1; }
  100% { transform: translateY(-62vh) scale(.9) rotate(var(--rot, 8deg)); opacity: 0; }
}

/* ============================================================
   Страничен панел (чат / участници)
   ============================================================ */

.panel {
  width: 348px; flex: none; display: flex; flex-direction: column; min-height: 0;
  border-radius: var(--r-lg); overflow: hidden;
}
.room:not(.panel-open) .panel { display: none; }

.panel-tabs { display: flex; gap: 4px; padding: 10px 10px 0; }
.panel-tab {
  flex: 1; height: 38px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center; gap: 7px;
  color: var(--text-2); font-size: 13.5px; font-weight: 550;
  transition: background .16s, color .16s;
}
.panel-tab:hover { background: var(--surface-2); color: var(--text); }
.panel-tab.active { background: var(--surface-2); color: var(--text); }
.panel-tab .count {
  min-width: 20px; height: 18px; padding: 0 6px; border-radius: var(--r-full);
  background: var(--surface-3); color: var(--text-2);
  font-size: 11px; font-weight: 600; display: grid; place-items: center;
}
.panel-close { margin-left: 4px; width: 38px; height: 38px; border-radius: var(--r-sm); display: grid; place-items: center; color: var(--text-2); }
.panel-close:hover { background: var(--surface-2); color: var(--text); }

.panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; }
.panel-view { display: none; }
.panel-view.active { display: block; }

/* Чат */
.msg { margin-bottom: 16px; }
.msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.msg-author { font-size: 13px; font-weight: 600; }
.msg-time { font-size: 11px; color: var(--text-3); }
.msg-body {
  background: var(--surface-2); border-radius: 4px var(--r-md) var(--r-md) var(--r-md);
  padding: 9px 12px; font-size: 14px; color: var(--text); word-wrap: break-word;
}
.msg.is-me .msg-head { justify-content: flex-end; }
.msg.is-me .msg-body { background: var(--accent); color: #fff; border-radius: var(--r-md) 4px var(--r-md) var(--r-md); }
.msg.is-system { text-align: center; }
.msg.is-system .msg-body { background: none; color: var(--text-3); font-size: 12px; padding: 4px; }

.chat-empty { text-align: center; color: var(--text-3); padding: 40px 20px; font-size: 13px; }

.chat-form { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); flex: none; }
.chat-form .field { height: 42px; padding: 0 14px; background: var(--surface-2); }
.chat-form .send {
  width: 42px; height: 42px; flex: none; border-radius: var(--r-full);
  background: var(--accent); color: #fff; display: grid; place-items: center;
  transition: background .16s, transform .16s var(--ease);
}
.chat-form .send:hover { background: #5d98ff; }
.chat-form .send:active { transform: scale(.93); }

/* Участници */
.person { display: flex; align-items: center; gap: 11px; padding: 8px 6px; border-radius: var(--r-sm); }
.person:hover { background: var(--surface-2); }
.person .avatar-sm {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 13px; font-weight: 600; color: #fff;
}
.person-name { flex: 1; min-width: 0; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-name .you { color: var(--text-3); font-weight: 400; }
.person-role { font-size: 11px; color: var(--text-3); }
.person-icons { display: flex; gap: 8px; color: var(--text-3); }
.person-icons .muted { color: var(--danger); }
.person-icons .hand { color: var(--accent); }

.panel-section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-3); font-weight: 600; margin: 4px 6px 8px;
}

/* ============================================================
   Меню, toast, модал
   ============================================================ */

.menu {
  position: absolute; z-index: 80; min-width: 218px; padding: 6px;
  border-radius: var(--r-md);
  opacity: 0; transform: translateY(6px); pointer-events: none;
  transition: opacity .16s var(--ease), transform .16s var(--ease);
}
.menu.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border-radius: 9px; font-size: 14px; text-align: left;
}
.menu button:hover { background: var(--surface-3); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 4px; }

/* ============================================================
   Модални прозорци (настройки, покана)
   ============================================================ */

.modal {
  position: fixed; inset: 0; z-index: 95;
  display: grid; place-items: center; padding: 20px;
  background: rgba(10, 12, 20, .55); backdrop-filter: blur(4px);
  animation: fadeIn .18s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  width: min(520px, 100%); max-height: 88dvh; overflow: auto;
  border-radius: var(--r-xl);
  animation: cardIn .22s var(--ease);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 22px 6px;
}
.modal-head h2 { margin: 0; font-size: 18px; letter-spacing: -.02em; }
.modal-x {
  width: 34px; height: 34px; border-radius: var(--r-full);
  display: grid; place-items: center; color: var(--text-2);
}
.modal-x:hover { background: var(--surface-2); color: var(--text); }

.modal-body { padding: 10px 22px 6px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px 20px;
}

.form-row { display: block; margin-bottom: 20px; }
.form-label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--text-2); margin-bottom: 8px;
}
.form-row .field { height: 46px; background: var(--surface-2); }
.form-hint { margin: 8px 0 0; font-size: 12px; color: var(--text-3); }
.form-note {
  margin: 4px 0 0; padding: 11px 13px; border-radius: var(--r-sm);
  background: var(--accent-soft); color: var(--text-2); font-size: 12.5px;
}

.logo-row { display: flex; gap: 16px; align-items: flex-start; }
.logo-preview {
  width: 82px; height: 82px; flex: none; border-radius: var(--r-md);
  background: #fff; border: 1px solid var(--border);
  display: grid; place-items: center; padding: 10px;
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-preview img.is-placeholder { opacity: .3; filter: grayscale(1); }
.logo-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.logo-actions .btn { height: 38px; padding: 0 14px; font-size: 13px; }
.logo-actions .form-hint { flex-basis: 100%; }

.link-box { display: flex; gap: 8px; margin-top: 14px; }
.link-box input {
  flex: 1; min-width: 0; height: 46px; padding: 0 16px;
  border-radius: var(--r-full); border: 1px solid var(--border);
  background: var(--surface-2); font-size: 13.5px; outline: none;
}
.link-box input:focus { border-color: var(--accent); }
.link-box .btn { flex: none; height: 46px; }

/* Контроли само за домакина */
body:not(.is-host) .host-only { display: none !important; }
.host-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: var(--r-full);
  background: var(--accent-soft); color: var(--accent);
  font-size: 11px; font-weight: 600;
}

@media (max-width: 560px) {
  .hide-sm { display: none; }
  #inviteBtn { padding: 0 12px !important; }
  .logo-row { flex-direction: column; }
  .modal-card { border-radius: var(--r-lg); }
}

.toast-layer {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: 74px; z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 16px; border-radius: var(--r-full);
  font-size: 13.5px;
  animation: toastIn .28s var(--ease);
}
.toast .icon { color: var(--accent); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

/* ============================================================
   Край на срещата (ended.html)
   ============================================================ */

.ended {
  height: 100dvh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(760px 520px at 18% 0%, var(--mesh-1), transparent 62%),
    radial-gradient(700px 480px at 88% 96%, var(--mesh-2), transparent 58%),
    var(--bg);
  overflow: auto;
}
.ended-card {
  width: min(480px, 100%); text-align: center;
  border-radius: var(--r-xl); padding: 40px 32px;
}
.ended-icon {
  width: 64px; height: 64px; margin: 0 auto 22px; border-radius: 22px;
  display: grid; place-items: center; background: var(--surface-2); color: var(--text-2);
}
.ended-card h1 { margin: 0 0 8px; font-size: 26px; letter-spacing: -.02em; }
.ended-card p { margin: 0 0 26px; color: var(--text-2); font-size: 15px; }
.ended-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 26px;
}
.stat { background: var(--surface-2); border-radius: var(--r-md); padding: 14px 8px; }
.stat b { display: block; font-size: 19px; letter-spacing: -.02em; }
.stat span { font-size: 11.5px; color: var(--text-3); }
.ended-actions { display: grid; gap: 10px; }

/* ============================================================
   Адаптивност
   ============================================================ */

@media (max-width: 1024px) {
  .lobby-main { grid-template-columns: 1fr; padding-bottom: 48px; }
  .lobby-copy { order: 2; }
  .prejoin { order: 1; }
  .panel { width: 310px; }
}

@media (max-width: 860px) {
  body { font-size: 14.5px; }

  .topbar { padding: 10px 12px; }
  .topbar .ctl { width: 36px; height: 36px; }
  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    left: 10px; right: 10px; padding: 7px 8px;
  }
  .topbar .brand { display: none; }          /* мястото отива за заглавието */
  .meeting-sub { font-size: 11.5px; white-space: nowrap; overflow: hidden; }
  .meeting-meta h1 { font-size: 13.5px; }
  .stage-wrap {
    padding: calc(72px + env(safe-area-inset-top)) 10px
             calc(86px + env(safe-area-inset-bottom));
  }
  .grid {
    gap: 8px;
    grid-template-columns: repeat(var(--cols-m, 2), minmax(0, 1fr));
    grid-template-rows: repeat(var(--rows-m, 3), minmax(0, 1fr));
  }
  .filmstrip .tile { width: 108px; }

  .controls { padding: 12px 10px calc(14px + env(safe-area-inset-bottom)); gap: 8px; }
  .controls-left, .controls-right { display: none; }         /* на телефон — само основните 5 */
  .controls-center { background: none; border: 0; box-shadow: none; padding: 0; gap: 10px; }
  .controls-center .ctl:not(.is-end):not(.is-off):not(.is-on) { background: var(--ctl-bg); }
  :root { --ctl: 50px; }

  /* Панелът става слой върху цялата стая */
  .panel {
    position: fixed; inset: 0; width: auto; z-index: 85;
    border-radius: 0; border: 0;
    animation: panelIn .26s var(--ease);
  }
  @keyframes panelIn { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
  .panel-tabs { padding: calc(10px + env(safe-area-inset-top)) 10px 0; }
  .chat-form { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}

@media (max-width: 560px) {
  .lobby-nav { padding: 18px; }
  .lobby-main { padding: 8px 18px 40px; }
  .ended-card { padding: 30px 22px; }

  /* На телефон всичко се подрежда в една колона. Важно: в колонен flex
     `flex-basis` управлява ВИСОЧИНАТА, затова полетата се фиксират. */
  .join-row { flex-direction: column; }
  .join-row .btn { width: 100%; }
  .join-row .field { flex: none; width: 100%; height: 52px; }

  .prejoin-foot { flex-direction: column; align-items: stretch; }
  .prejoin-foot .btn { width: 100%; height: 48px !important; flex: none; }
  .prejoin-foot .field { flex: none; width: 100%; height: 48px; }
  .prejoin-stage .placeholder { padding-bottom: 74px; }   /* текстът да не влиза под бутоните */
  .lobby-copy h1 { font-size: clamp(28px, 8vw, 38px); }
  .lobby-copy p.lead { font-size: 15.5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
