:root{
  --bg:#0b1220; --panel:#0f172a; --panel-2:#111827; --border:#1f2b43; --text:#e6eef8;
  --muted:#94a3b8; --accent:#3b82f6; --danger:#ef4444; --ok:#22c55e; --radius:18px; --tap:52px;
  --pad:12px; --thumb-h:110px;
}
body[data-theme="light"]{
  --bg:#edf2fb;
  --panel:#f8fbff;
  --panel-2:#eef4ff;
  --border:#c9d7f0;
  --text:#14233f;
  --muted:#4e658f;
  --accent:#2563eb;
  --danger:#dc2626;
  --ok:#16a34a;
}
body[data-theme="light"]{
  background:
    radial-gradient(1200px 600px at 10% -10%, #dfeaff 0%, transparent 55%),
    radial-gradient(1000px 500px at 100% 0%, #e8f2ff 0%, transparent 50%),
    #e9eef7;
}
*{ box-sizing:border-box } html,body{ height:100% }
body{
  margin:0; background:var(--bg); color:var(--text);
  font:15px/1.35 system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  display:block;
  padding:8px;
}
body.prejoin-open .meet-window{
  visibility:hidden;
  pointer-events:none;
}

.meet-window{
  width:min(1900px,calc(100vw - 16px));
  height:calc(100dvh - 16px);
  margin:0 auto;
  background:var(--panel); border:1px solid var(--border); border-radius:22px;
  display:grid; grid-template-rows:auto 1fr auto; overflow:hidden;
  box-shadow:0 20px 60px rgba(0,0,0,.4)
}
.topbar{ display:flex; align-items:center; justify-content:space-between; padding:10px 14px; border-bottom:1px solid var(--border); background:var(--panel-2) }
.topbar .left{ display:flex; align-items:center; gap:10px } .brand{ font-weight:700; line-height:1.2 } .divider{ width:1px; height:18px; background:var(--border) }
.brand-wrap{ display:flex; flex-direction:column; gap:0 }
.brand-sub{ font-size:11px; color:var(--muted); font-weight:400; max-width:200px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap }
.lesson-info-topbar-btn{
  background:none; border:none; padding:2px; margin:0; cursor:pointer;
  color:var(--muted); display:inline-flex; align-items:center; justify-content:center;
  border-radius:6px; transition:color .15s;
}
.lesson-info-topbar-btn:hover{ color:var(--text); }
.topbar .right{ display:flex; align-items:center; gap:8px; }
.badge{
  padding:3px 8px;
  border:1px solid var(--border);
  border-radius:999px;
  color:var(--muted);
  font-size:12px;
  display:inline-flex;
  align-items:center;
  gap:6px;
}
.badge .ico{
  width:14px;
  height:14px;
}
.pill{ display:inline-flex; align-items:center; gap:6px; padding:4px 10px; border:1px solid var(--border); border-radius:999px; font-size:12px; color:var(--muted) }
.pill.danger{ color:var(--danger); border-color:#3a1f23 }
.link{ color:#c5d4ff; text-decoration:none; border:1px solid var(--border); border-radius:999px; padding:4px 10px; font-size:13px; display:inline-flex; align-items:center; gap:6px }
.ico{ width:18px; height:18px }
.icon{
  inline-size:var(--tap);
  block-size:var(--tap);
  flex-shrink:0;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:0;
  line-height:1;
  font-size:20px;
  border:1px solid var(--border);
  background:#0f172a;
  color:#fff;
  border-radius:12px;
  appearance:none;
  -webkit-appearance:none;
}
.icon.ghost{ background:transparent } .icon.danger{ background:#2a1316; color:#ffb4b4; border-color:#4b1f24 } .icon.active{ background:#1e3a6e; color:#93c5fd; border-color:#2563eb }
.icon .ico, .icon svg{
  width:22px;
  height:22px;
  display:block;
  margin:0;
  flex:0 0 auto;
}
body[data-theme="light"] .icon{ background:transparent; border-color:transparent; color:#374151; }
body[data-theme="light"] .icon:hover{ background:rgba(0,0,0,.06); border-color:transparent; }
body[data-theme="light"] .icon.ghost{ background:transparent; border-color:transparent; color:#374151; }
body[data-theme="light"] .icon.ghost:hover{ background:rgba(0,0,0,.06); }
body[data-theme="light"] .icon.danger{ background:transparent; border-color:transparent; color:#dc2626; }
body[data-theme="light"] .icon.danger:hover{ background:#fee2e2; border-color:transparent; }
body[data-theme="light"] .icon.active{ background:rgba(37,99,235,.12); border-color:transparent; color:#1d4ed8; }
body[data-theme="light"] .meet-window{
  background:#fdfefe;
  border-color:#d6e0f2;
  box-shadow:0 16px 42px rgba(33,56,99,.16);
}
body[data-theme="light"] .topbar{
  background:#eef4ff;
  border-bottom-color:#d6e0f2;
}
body[data-theme="light"] .badge{
  background:#f7faff;
  color:#33507d;
}
body[data-theme="light"] .link{
  color:#1d4ed8;
}

.content{
  position:relative;
  display:flex;
  flex-direction:column;
  min-height:0;
  overflow:hidden;
}
.screen-panel{
  display:none;
  margin:4px 6px 0;
  border:1px solid #2c3e61;
  border-radius:16px;
  background:linear-gradient(180deg,#0f172a 0%, #0b1220 100%);
  overflow:hidden;
}
.screen-panel__head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  border-bottom:1px solid var(--border);
  background:#0e1629;
}
.screen-panel__title{
  font-weight:700;
  letter-spacing:.2px;
}
.screen-panel__status{
  color:var(--muted);
  font-size:12px;
}
.screen-panel__tools{
  display:flex;
  align-items:center;
  gap:10px;
}

#screenFocusBtn{
  width:42px;
  height:42px;
  min-width:42px;
  min-height:42px;
  padding:0;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:12px;
  flex:0 0 auto;
}

#screenFocusBtn .ico{
  width:20px;
  height:20px;
  display:block;
  margin:0;
  transform:translate(0, 0);
}

body.has-share .screen-panel{ display:flex; flex-direction:column; flex:1 1 0; min-height:0; }
body.has-teacher-layout .screen-panel{ display:flex; flex-direction:column; flex:1 1 0; min-height:0; }
body.has-teacher-layout .content{
  display:flex;
  flex-direction:column;
  min-height:0;
  align-items:stretch;
  overflow-y:auto;
  overflow-x:hidden;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior-y:contain;
}
body[data-theme="light"] .content{
  background:
    linear-gradient(180deg,#f8fbff 0%, #f2f7ff 100%);
}
body[data-theme="light"] .screen-panel{
  border-color:#c7d8f6;
  background:linear-gradient(180deg,#f7fbff 0%, #f0f6ff 100%);
}
body[data-theme="light"] .screen-panel__head{
  background:#edf4ff;
  border-bottom-color:#d2dff4;
}
.sidebar{
  position:absolute; right:12px; top:12px; bottom:12px; width:clamp(320px,30vw,420px);
  background:rgba(15,23,42,.95); border:1px solid var(--border); border-radius:14px;
  padding:12px; z-index:5; transform:translateX(110%); transition:transform .25s ease;
  display:flex; flex-direction:column; gap:10px;
  min-height:0;
  overflow:hidden;
  visibility:hidden;
  pointer-events:none;
}
.sidebar.open{
  transform:translateX(0%);
  visibility:visible;
  pointer-events:auto;
}
.sidebar__header{ display:flex; align-items:center; justify-content:space-between; border-bottom:1px solid var(--border); padding-bottom:8px; margin-bottom:2px }
.sidebar__content{
  flex:1 1 auto;
  min-height:0;
  overflow-y:auto;
  overflow-x:hidden;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior:contain;
  display:grid;
  gap:12px;
  padding-right:4px;
  padding-bottom:8px;
}
.card{ background:#0b1220; border:1px solid var(--border); border-radius:14px; padding:12px 14px }
.card h4{ margin:0 0 8px; font-size:14px; font-weight:700; }
.list{ list-style:none; padding:0; margin:0; display:grid; gap:8px }
.chatlog{ height:240px; overflow:auto; border:1px solid var(--border); border-radius:10px; padding:12px; background:#0b1220 }
#chat-log{ height:clamp(140px, 22vh, 190px); }
body[data-theme="light"] .card,
body[data-theme="light"] .chatlog{
  background:#ffffff;
}
body[data-theme="light"] .sidebar{
  background:rgba(248,251,255,.98);
  border-color:#d2def3;
  box-shadow:0 16px 32px rgba(43,64,104,.16);
}
body[data-theme="light"] .sidebar__header{
  border-bottom-color:#d7e2f4;
}
body[data-theme="light"] .card{
  border-color:#d4e0f3;
}

.grid{
  display:grid; gap:12px; padding:12px 12px 90px;
  grid-template-columns:repeat(auto-fill,minmax(260px,1fr));
  align-content:start; grid-auto-flow:dense;
  overflow:auto;
}
.tile{ position:relative; border:1px solid var(--border); border-radius:14px; background:#000; overflow:hidden; min-width:160px; min-height:120px; resize:none } /* base */
.tile::before{ content:""; display:block; padding-top:56.25% }
.tile>video{ position:absolute; inset:0; width:100%; height:100%; object-fit:cover; background:#000 }
.label{ position:absolute; left:8px; bottom:8px; background:rgba(0,0,0,.45); color:#fff; padding:4px 8px; border-radius:8px; font-size:12px; backdrop-filter:blur(4px) }
/* Indicatori stato mic/cam sul tile video */
.tile-indics{
  position:absolute;
  top:6px;
  left:6px;
  display:flex;
  gap:4px;
  z-index:3;
  pointer-events:none;
}
.tile-ind{
  width:22px;
  height:22px;
  border-radius:6px;
  background:rgba(0,0,0,.6);
  backdrop-filter:blur(3px);
  display:none;
  align-items:center;
  justify-content:center;
  color:#f87171;
}
.tile-ind.active{ display:flex; }
.tile-ind .ico{ width:13px; height:13px; }
.tile-audio-badge{
  position:absolute;
  inset:0;
  z-index:2;
  display:none;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  gap:8px;
  color:rgba(241,245,249,.95);
  background:rgba(10,16,30,.72);
  pointer-events:none;
}
.tile-audio-badge .ico{ width:36px; height:36px; opacity:.9; }
.tile-audio-badge span{
  font-size:12px;
  font-weight:700;
  letter-spacing:.02em;
}
.tile-audio-badge__meta{
  display:none;
  max-width:78%;
  text-align:center;
  font-size:11px !important;
  font-weight:600 !important;
  line-height:1.35;
  color:rgba(226,232,240,.82);
}
.tile-audio-badge__meta.show{ display:block; }
.tile.audio-only .tile-audio-badge{ display:flex; }
.tile.audio-only > video{ opacity:0; }
.tile-gesture-badge{
  position:absolute;
  right:8px;
  top:8px;
  z-index:7;
  min-width:34px;
  height:30px;
  padding:0 8px;
  border-radius:999px;
  display:none;
  align-items:center;
  justify-content:center;
  font-size:20px;
  background:rgba(5,10,20,.62);
  color:#fff;
  backdrop-filter:blur(5px);
  box-shadow:0 6px 16px rgba(0,0,0,.35);
}
.tile-gesture-badge.show{
  display:flex;
  animation:gesturePop .28s ease-out;
}
@keyframes gesturePop{
  from{ transform:scale(.65); opacity:0; }
  to{ transform:scale(1); opacity:1; }
}
/* Overlay centrato quando la camera è disattivata */
.tile.audio-only::after{
  content:'';
  position:absolute;
  inset:0;
  z-index:1;
  pointer-events:none;
  background: rgba(10,16,30,.72);
}
.tile:not(.audio-only):has(.tile-ind--cam.active)::after{
  content:'';
  position:absolute;
  inset:0;
  z-index:2;
  pointer-events:none;
  background:
    rgba(10,16,30,.72)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,.45)' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m2 2 20 20'/%3E%3Cpath d='M10.66 6H14a2 2 0 0 1 2 2v2.34l1 1L22 9v6'/%3E%3Cpath d='M16 16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2l10 10z'/%3E%3C/svg%3E")
    center/44px no-repeat;
}
.tile .resizer{
  position:absolute;
  right:6px;
  bottom:6px;
  width:14px;
  height:14px;
  cursor:se-resize;
  opacity:.75;
  background:
    linear-gradient(135deg, transparent 0 45%, rgba(230,238,248,.8) 46% 54%, transparent 55% 100%);
}

/* === BOTTOM BAR: con safe-area === */
.bottombar{
  position: sticky;
  left: auto; right: auto; bottom: 0;
  width:100%;
  display: flex; justify-content: center; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(15,23,42,0.8) 0%, rgba(15,23,42,0.95) 80%);
  backdrop-filter: blur(8px);
  z-index: 40;
  box-shadow: 0 -2px 12px rgba(0,0,0,.4);
}
/* leggera risalita su desktop per evitare “otticamente basso” */
@media (hover:hover){
  .bottombar{ border-radius:12px; }
}
body[data-theme="light"] .bottombar{
  background:linear-gradient(180deg, rgba(245,245,245,.80) 0%, rgba(238,238,238,.97) 88%);
  border-top-color:#e0e0e0;
  box-shadow:0 -2px 10px rgba(0,0,0,.07);
}

/* == MODAL / PREJOIN (verticale, più piccolo) == */
.modal{ position:fixed; inset:0; background:rgba(9,13,23,.6); display:none; place-items:center; padding:16px; z-index:15000; animation:fadeIn .2s ease }
.modal.open{ display:grid }
@keyframes fadeIn{ from{opacity:0} to{opacity:1} }
.modal__panel{
  width:min(720px,94vw); background:var(--panel); border:1px solid var(--border);
  border-radius:18px; padding:16px; box-shadow:0 20px 60px rgba(0,0,0,.5);
  max-height:min(82dvh,640px); overflow:auto
}
/* ======= Waiting room v3 — layout ispirato al design moderno ======= */

/* Override del panel base per il nuovo layout flex-column */
#waitingOverlay .modal__panel{
  max-width:min(440px, 95vw);
  width:min(440px, 95vw);
  max-height:min(90dvh, 720px);
  padding:0;
  overflow:hidden;
  display:flex;
  flex-direction:column;
}

/* Header con orologio animato */
.wr-hd{
  text-align:center;
  padding:28px 24px 20px;
  border-bottom:1px solid rgba(255,255,255,.07);
  flex-shrink:0;
}
.wr-clock-wrap{
  width:58px;
  height:58px;
  margin:0 auto 14px;
  display:flex;
  align-items:center;
  justify-content:center;
}
.wr-clock-ico{ width:58px; height:58px; color:#4f93ff; }
.wr-title{
  margin:0 0 5px;
  font-size:21px;
  font-weight:700;
  letter-spacing:-.3px;
}
.wr-subtitle{
  margin:0;
  color:var(--muted);
  font-size:13px;
  line-height:1.5;
}

/* Corpo scrollabile */
.wr-body{
  flex:1 1 auto;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior-y:contain;
  padding:16px;
  display:flex;
  flex-direction:column;
  gap:14px;
}

/* Card azione campanella */
.wr-action-card{
  border:1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  border-radius:16px;
  padding:16px;
  background:color-mix(in srgb, var(--accent) 9%, var(--panel));
}
.wr-action-hd{
  display:flex;
  align-items:center;
  gap:8px;
  margin-bottom:6px;
  color:color-mix(in srgb, var(--accent) 80%, #6ea8ff);
}
.wr-action-ico{ width:18px; height:18px; flex-shrink:0; }
.wr-action-title{ font-weight:600; font-size:15px; color:var(--text); }
.wr-action-desc{
  margin:0 0 14px;
  font-size:13px;
  color:var(--muted);
  line-height:1.5;
}

/* Pulsante campanella full-width */
.bell-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  width:100%;
  border:1px solid #2b69d9;
  background:linear-gradient(180deg,#4f93ff 0%, #3477e9 100%);
  box-shadow:0 6px 18px rgba(59,130,246,.28);
  padding:13px 16px;
  font-size:15px;
}
.bell-btn .ico{ width:18px; height:18px; }
.bell-btn:hover{ filter:brightness(1.06); }
.bell-btn:active{ transform:scale(.98); }
.bell-btn:disabled{ opacity:.7; cursor:not-allowed; box-shadow:none; }
.bell-btn.cooldown{ filter:saturate(.6); }
.bell-btn span{ font-weight:700; }

.waiting-send-status{
  display:none;
  font-size:12px;
  line-height:1.4;
  color:var(--muted);
  margin-top:6px;
}

/* Textarea con tasto invia inline */
.wr-msg-wrap{ position:relative; margin-top:12px; }
.waiting-textarea{
  width:100%; box-sizing:border-box;
  resize:none; min-height:80px;
  border-radius:12px; border:1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  background:color-mix(in srgb, var(--panel) 88%, var(--surface-2,#0b1220));
  color:var(--text); padding:10px 44px 10px 12px; font:inherit;
  font-size:14px;
  transition:border-color .15s, box-shadow .15s;
}
.waiting-textarea:focus{
  outline:none;
  border-color:color-mix(in srgb, var(--accent) 70%, white);
  box-shadow:0 0 0 3px color-mix(in srgb, var(--accent) 24%, transparent);
}
.wr-send-btn{
  position:absolute;
  bottom:8px; right:8px;
  width:30px; height:30px;
  border-radius:8px;
  background:var(--accent);
  border:none;
  color:#fff;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer; padding:0;
  transition:background .15s, transform .1s;
}
.wr-send-btn:hover{ background:#2563eb; }
.wr-send-btn:active{ transform:scale(.92); }

/* Sezione chat */
.wr-chat-section{ display:flex; flex-direction:column; }
.wr-chat-label{
  margin:0 0 8px;
  font-size:10px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.1em;
  color:var(--muted);
}

.wr-games-section{ display:flex; flex-direction:column; gap:8px; }
.wr-games-toggle{
  border:1px solid var(--border);
  border-radius:12px;
  background: linear-gradient(135deg, var(--panel), color-mix(in srgb, var(--panel) 82%, var(--accent)));
  color: var(--text);
  text-align:left;
  padding:11px 12px;
  display:flex;
  flex-direction:column;
  gap:3px;
}
.wr-games-toggle-main{ font-size:13px; font-weight:800; }
.wr-games-toggle-sub{ font-size:11px; color:var(--muted); }
.wr-games-modal{
  position:fixed;
  inset:0;
  z-index:54;
  display:none;
  align-items:flex-end;
  justify-content:center;
  padding:16px 12px calc(88px + env(safe-area-inset-bottom, 0px));
  background: rgba(2,6,23,.48);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.wr-games-sheet{
  width:min(520px, 100%);
  max-height:min(74vh, 560px);
  overflow:auto;
  border:1px solid var(--border);
  border-radius:14px;
  padding:10px;
  background: linear-gradient(180deg, var(--panel), color-mix(in srgb, var(--panel) 85%, var(--surface-2,#0b1220)));
  display:flex;
  flex-direction:column;
  gap:8px;
  box-shadow: 0 16px 36px rgba(0,0,0,.35);
}
.wr-games-top{ display:flex; align-items:center; justify-content:space-between; gap:8px; }
.wr-games-title{
  font-size:12px; font-weight:800; letter-spacing:.08em; text-transform:uppercase; color:var(--muted);
}
.wr-games-close{
  border:1px solid var(--border);
  border-radius:8px;
  background: var(--panel);
  color:var(--text);
  font-size:11px;
  font-weight:800;
  padding:5px 8px;
}
.wr-games-tabs{ display:grid; grid-template-columns:repeat(4,1fr); gap:6px; }
.wr-game-tab{
  border:1px solid var(--border);
  border-radius:8px;
  background: var(--panel);
  color: var(--text);
  font-size:11px;
  font-weight:800;
  padding:6px 7px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:5px;
}
.wr-game-tab.active{
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.game-tab__ico{ font-size:13px; line-height:1; }
.wr-game-panel{ display:flex; flex-direction:column; gap:8px; position:relative; }
.wr-level-hint{
  font-size:11px;
  color:var(--muted);
  border:1px dashed color-mix(in srgb, var(--accent) 34%, var(--border));
  background:color-mix(in srgb, var(--accent) 8%, var(--panel));
  border-radius:8px;
  padding:5px 8px;
}
.wr-game-status{ font-size:12px; color:var(--muted); min-height:18px; }
.wr-game-btn{
  border:1px solid var(--border);
  border-radius:8px;
  background: var(--panel);
  color: var(--text);
  font-size:12px;
  font-weight:800;
  padding:6px 10px;
  align-self:flex-start;
}
.wr-levels{ display:flex; gap:6px; flex-wrap:wrap; }
.wr-level-btn{
  border:1px solid var(--border);
  border-radius:7px;
  background: var(--panel);
  color: var(--muted);
  font-size:11px;
  font-weight:800;
  padding:4px 8px;
}
.wr-level-btn.active{
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.wr-ttt-board{ display:grid; grid-template-columns:repeat(3,1fr); gap:6px; }
.wr-ttt-cell{
  border:1px solid var(--border); border-radius:9px; background:var(--panel);
  height:38px; font-size:18px; font-weight:900; color:var(--text);
}

.wr-mem-board{ display:grid; grid-template-columns:repeat(4,1fr); gap:6px; }
.wr-mem-card{
  border:1px solid var(--border); border-radius:9px; background:var(--panel);
  height:34px; font-size:18px; font-weight:900; color:transparent;
}
.wr-mem-card.open,.wr-mem-card.matched{ color:var(--text); background:var(--accent-dim); }

.wr-snake-head{ display:flex; align-items:center; justify-content:space-between; gap:8px; }
.wr-snake-score{
  border:1px solid var(--border); border-radius:8px; padding:4px 8px;
  font-size:12px; font-weight:800; color:var(--text); background:var(--panel);
}
.wr-snake-layout{ display:grid; gap:12px; align-items:start; }
.wr-snake-main{ min-width:0; }
.wr-snake-board{
  display:grid; gap:2px;
  width:min(72vmin, 460px);
  margin:0 auto;
  border:1px solid var(--border); border-radius:9px; padding:4px; background:var(--surface-2,#0b1220);
}
.wr-snake-cell{ aspect-ratio:1/1; min-height:11px; border-radius:3px; background: rgba(148,163,184,.16); }
.wr-snake-cell.snake{ background:#22c55e; }
.wr-snake-cell.head{ background:#86efac; }
.wr-snake-cell.food{ background:#fb7185; }
.wr-snake-side{ display:flex; flex-direction:column; gap:8px; align-items:center; }
.wr-snake-pad{ display:grid; grid-template-columns:repeat(3,1fr); gap:8px; width:min(280px, 100%); }
.wr-snake-dir,.wr-snake-start{
  height:40px; border:1px solid var(--border); border-radius:10px;
  background:var(--panel); color:var(--text); font-size:15px; font-weight:900;
}
.wr-snake-start{ font-size:12px; min-width:140px; }
.wr-snake-pad-core{
  height:40px;
  border-radius:10px;
  border:1px dashed var(--border);
  color:var(--muted);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:12px;
}
.wr-snake-kbd-hint{ font-size:11px; color:var(--muted); }

.wr-sudoku-board{
  display:grid; grid-template-columns:repeat(9,1fr); gap:2px;
  border:1px solid var(--border); border-radius:9px; padding:4px; background:var(--surface-2,#0b1220);
}
.wr-sudoku-cell{
  height:26px; border:1px solid rgba(148,163,184,.25); border-radius:4px;
  background:var(--panel); color:var(--text); font-size:12px; font-weight:900;
}
.wr-sudoku-cell.fixed{ background:var(--accent-dim); color:var(--accent); }
.wr-sudoku-cell.sel{ border-color:#f59e0b; box-shadow: inset 0 0 0 1px #f59e0b; }
.wr-sudoku-cell.wrong{ background: rgba(239,68,68,.25); }
.wr-sudoku-pad{ display:grid; grid-template-columns:repeat(5,1fr); gap:6px; }
.wr-sudoku-num{
  height:32px; border:1px solid var(--border); border-radius:8px;
  background:var(--panel); color:var(--text); font-size:12px; font-weight:900;
}
.waiting-replies{
  height:auto;
  min-height:140px;
  max-height:200px;
}
.waiting-chat{
  display:flex;
  flex-direction:column;
  gap:8px;
  padding:10px;
  border:1px solid var(--border);
  border-radius:14px;
  background:rgba(0,0,0,.18);
  overflow-y:auto;
  min-height:140px;
  max-height:200px;
}
.waiting-chat .waiting-empty{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  flex:1;
  gap:10px;
  padding:20px 16px;
  text-align:center;
  color:var(--muted);
  font-size:13px;
  line-height:1.5;
}
.waiting-msg{
  max-width:86%;
  border:1px solid var(--border);
  border-radius:12px;
  padding:8px 10px;
  line-height:1.3;
  font-size:14px;
  word-break:break-word;
}
.waiting-msg--me{
  align-self:flex-end;
  background:rgba(59,130,246,.18);
  border-color:rgba(59,130,246,.45);
}
.waiting-msg--admin{
  align-self:flex-start;
  background:#0b1220;
  border-color:#2f4978;
}
.waiting-msg--system{
  align-self:center;
  background:rgba(148,163,184,.15);
  color:var(--muted);
  font-size:13px;
}

/* Footer pill */
.wr-footer{
  font-size:12px;
  line-height:1.6;
  text-align:center;
  color:var(--muted);
  background:rgba(59,130,246,.06);
  border:1px solid rgba(59,130,246,.16);
  border-radius:12px;
  padding:12px 14px;
}
.wr-footer p{ margin:0; }

/* Light theme */
body[data-theme="light"] .wr-action-card{
  background:rgba(59,130,246,.05);
  border-color:rgba(59,130,246,.28);
}
body[data-theme="light"] .wr-hd{
  border-bottom-color:#e6edf8;
}
body[data-theme="light"] .waiting-chat{
  background:#f7fbff;
  border-color:#d0dff2;
}
body[data-theme="light"] .waiting-msg--admin{
  background:#fff;
  border-color:#ccdaf2;
}
body[data-theme="light"] .waiting-msg--me{
  background:rgba(37,99,235,.1);
  border-color:rgba(37,99,235,.32);
}
body[data-theme="light"] .waiting-msg--system{
  background:#eef4ff;
  color:#4e658f;
}
body[data-theme="light"] .waiting-textarea{
  background:#fff;
  color:#14233f;
  border-color:#c0d3f0;
}
body[data-theme="light"] .wr-footer{
  background:#eff6ff;
  border-color:#bfdbfe;
  color:#3b5a8f;
}
body[data-theme="light"] .waiting-send-status{
  color:#43608f;
}
body[data-theme="light"] .wr-snake-pad-core{
  background:#f7fbff;
  border-color:#cfdcf1;
  color:#5b7095;
}
body[data-theme="light"] .modal{ background:rgba(57,74,103,.36); }
body[data-theme="light"] .modal__panel{
  background:#fdfefe;
  border-color:#d6e0f2;
  box-shadow:0 20px 48px rgba(39,62,100,.24);
}
body[data-theme="light"] .waiting-panel-v2{
  background:linear-gradient(180deg,#f7fbff 0%, #f2f7ff 100%);
}
body[data-theme="light"] .waiting-guide__pill{
  background:#eef4ff;
  border-color:#d3e1f6;
  color:#44608f;
}
body[data-theme="light"] .waiting-queue-badge{
  background:rgba(37,99,235,.10);
  color:#1d4ed8;
  border-color:#bfd0f2;
}
body[data-theme="light"] .waiting-textarea{
  background:#fff;
  color:#14233f;
  border-color:#c8d9f3;
}
body[data-theme="light"] .waiting-card--bell{
  background:linear-gradient(180deg,#ffffff 0%, #f6f9ff 100%);
  border-color:#c8d9f3;
}
body[data-theme="light"] .waiting-send-status{
  color:#43608f;
}
body[data-theme="light"] .waiting-msg--admin{
  background:#ffffff;
  border-color:#ccdaf2;
}
body[data-theme="light"] .waiting-msg--me{
  background:rgba(37,99,235,.12);
  border-color:rgba(37,99,235,.35);
}
body[data-theme="light"] .waiting-msg--system{
  background:#eef4ff;
  color:#4e658f;
  border-color:#d6e2f6;
}
/* Sala d'attesa: fix mobile */
@media (max-width:900px){
  #waitingOverlay{
    padding:0;
    align-items:stretch;
  }
  #waitingOverlay .modal__panel{
    max-width:100% !important;
    width:100% !important;
    max-height:100dvh !important;
    border-radius:0 !important;
    padding-bottom:env(safe-area-inset-bottom, 0px);
  }
  /* Header compatto: orologio più piccolo, meno spazio verticale */
  .wr-hd{
    padding:16px 18px 14px;
    border-bottom:1px solid rgba(255,255,255,.07);
  }
  .wr-clock-wrap{ width:44px; height:44px; margin-bottom:10px; }
  .wr-clock-ico{ width:44px; height:44px; }
  .wr-title{ font-size:17px; margin-bottom:3px; }
  .wr-subtitle{ font-size:12px; }
  /* Body: padding ridotto, gap stretto */
  .wr-body{ padding:12px 14px; gap:10px; }
  .wr-action-card{ padding:14px 14px 12px; }
  .wr-action-desc{ margin-bottom:10px; font-size:12px; }
  /* Pulsante campanella touch-friendly */
  .bell-btn{ padding:13px 14px; font-size:14px; }
  /* Textarea: font-size ≥16px per evitare zoom iOS */
  .waiting-textarea{ font-size:16px; min-height:72px; }
  /* Chat più compatta, lascia spazio alla textarea */
  .waiting-chat{ min-height:90px; max-height:150px; }
  /* Footer nascosto su schermi molto piccoli */
  .wr-footer{ padding:9px 12px; font-size:11px; }
  .wr-snake-board{ width:min(88vw, 360px); }
  .wr-snake-dir,.wr-snake-start,.wr-snake-pad-core{ height:36px; }
}
@media (min-width:1024px){
  .wr-games-modal{
    align-items:center;
    padding:20px 18px;
  }
  .wr-games-sheet{
    width:min(920px, 96vw);
    max-height:min(86vh, 860px);
    padding:14px;
    border-radius:16px;
  }
  .wr-games-tabs{
    grid-template-columns:repeat(4,minmax(120px,1fr));
    gap:8px;
  }
  .wr-game-tab{
    font-size:12px;
    padding:8px 10px;
  }
  .wr-snake-layout{
    grid-template-columns:minmax(420px,1fr) 220px;
    gap:14px;
    align-items:center;
  }
  .wr-snake-board{
    width:min(70vh, 560px);
    max-width:100%;
    border-radius:12px;
    padding:6px;
  }
  .wr-snake-cell{ min-height:14px; border-radius:4px; }
  .wr-snake-dir,.wr-snake-start,.wr-snake-pad-core{ height:46px; }
  .wr-snake-start{ width:100%; }
}
@media (max-width:480px){
  .wr-footer{ display:none; }
}
/* legacy prejoin classes – kept for compatibility but no longer used by main prejoin */
.dev-pick option{ background:#0f172a; color:#fff }
.entry-mode-switch{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
  margin:0 0 10px;
}
.entry-mode-btn{
  border:1px solid var(--border);
  background:#0b1220;
  color:#fff;
  border-radius:12px;
  padding:10px 12px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  font-weight:700;
  text-decoration:none;
  transition:border-color .15s, transform .12s, background .15s, color .15s;
}
.entry-mode-btn .ico{ width:16px; height:16px; }
.entry-mode-btn:hover{ border-color:#3f5f90; transform:translateY(-1px); }
.entry-mode-btn:active{ transform:translateY(0); }
.entry-mode-btn.is-active{
  background:rgba(59,130,246,.2);
  border-color:#3b82f6;
  color:#cfe2ff;
}
.form input{ width:100%; padding:12px; border-radius:12px; border:1px solid var(--border); background:#0b1220; color:#fff; margin-bottom:8px }
.row{ display:flex; gap:8px } button{ cursor:pointer } .primary{ background:var(--accent); border:1px solid #2b69d9; color:white; border-radius:12px; padding:10px 14px } .ghost{ background:transparent; border:1px solid var(--border); color:#fff; border-radius:12px; padding:10px 14px }
.hint{ color:var(--muted); font-size:13px }
body[data-theme="light"] .form input{
  background:#ffffff;
  color:#12233f;
}
body[data-theme="light"] .entry-mode-btn{
  background:#fff;
  color:#14284b;
  border-color:#d0dbef;
}
body[data-theme="light"] .entry-mode-btn:hover{
  border-color:#97b0d6;
}
body[data-theme="light"] .entry-mode-btn.is-active{
  background:#dbeafe;
  border-color:#60a5fa;
  color:#1d4ed8;
}
body[data-theme="light"] .ghost{
  color:#1e3a63;
  background:#f7faff;
  border-color:#d0dbef;
}
.record-targets-panel{ width:min(560px,94vw); }
.record-targets-actions{ display:flex; gap:8px; margin-bottom:10px; }
.record-targets-list{
  display:grid;
  gap:8px;
  max-height:min(45vh,360px);
  overflow:auto;
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px;
  background:#0b1220;
}
.record-target-item{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px;
  border:1px solid var(--border);
  border-radius:10px;
  background:#0b1220;
}
.record-target-item input[type="checkbox"]{
  width:18px;
  height:18px;
  accent-color:var(--accent);
}
.record-target-name{ font-weight:600; }
.record-target-meta{ color:var(--muted); font-size:12px; }
body[data-theme="light"] .record-targets-list{
  background:#f7fbff;
  border-color:#cfdbf0;
}
body[data-theme="light"] .record-target-item{
  background:#ffffff;
  border-color:#cfdbf0;
}
body[data-theme="light"] .record-target-name{
  color:#14233f;
}
.waiting-item{
  display:grid;
  grid-template-columns:1fr;
  gap:10px;
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px;
  background:#0b1220;
}
body[data-theme="light"] .waiting-item{
  background:#ffffff;
}
.waiting-item .meta{
  min-width:0;
}
.waiting-item .name{
  font-weight:600;
  font-size:18px;
  line-height:1.25;
  word-break:break-word;
}
.waiting-item .sub{
  color:var(--muted);
  font-size:12px;
}
.waiting-item .msg{
  margin-top:4px;
  font-size:12px;
  color:#dbeafe;
  background:#111b32;
  border:1px solid #22345f;
  border-radius:8px;
  padding:6px 8px;
  max-width:320px;
}
body[data-theme="light"] .waiting-item .msg{
  color:#1e355f;
  background:#eef4ff;
  border-color:#cddcf6;
}
.waiting-actions{
  display:grid;
  grid-template-columns:repeat(3, minmax(0,1fr));
  gap:8px;
}
.waiting-actions > button{
  width:100%;
  min-width:0;
  padding:10px 8px;
  white-space:nowrap;
}
.waiting-prompt{
  position:fixed;
  top:14px;
  left:16px;
  right:auto;
  z-index:12000;
  width:min(360px, calc(100vw - 24px));
  background:#172542;
  border:1px solid #3b82f6;
  border-radius:12px;
  padding:10px 12px;
  box-shadow:0 8px 24px rgba(0,0,0,.35);
  animation:waitingPulse 1.2s ease-in-out infinite;
}
body[data-theme="light"] .waiting-prompt{
  background:#ffffff;
  color:#17325b;
  border-color:#bfd3f7;
  box-shadow:0 8px 24px rgba(52,84,142,.18);
}
.waiting-prompt__hd{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:6px;
}
.waiting-prompt__min{
  flex-shrink:0;
  width:20px;
  height:20px;
  padding:0;
  display:flex;
  align-items:center;
  justify-content:center;
  border:1px solid rgba(255,255,255,.2);
  border-radius:5px;
  background:transparent;
  color:rgba(255,255,255,.7);
  cursor:pointer;
}
.waiting-prompt__min:hover{ background:rgba(255,255,255,.1); color:#fff; }
body[data-theme="light"] .waiting-prompt__min{ border-color:rgba(35,66,119,.25); color:#355a90; }
body[data-theme="light"] .waiting-prompt__min:hover{ background:rgba(35,66,119,.08); }
/* Tile context menu */
.tile-ctx-menu{
  position:fixed;
  z-index:99999;
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:10px;
  padding:4px;
  box-shadow:0 4px 20px rgba(0,0,0,.45);
  min-width:180px;
}
.tile-ctx-item{
  width:100%;
  padding:8px 12px;
  text-align:left;
  background:transparent;
  border:none;
  border-radius:7px;
  color:var(--text);
  font-size:13px;
  cursor:pointer;
  display:flex;
  align-items:center;
  gap:8px;
  white-space:nowrap;
}
.tile-ctx-item:hover{ background:var(--border); }
.waiting-mini-count{
  position:absolute;
  top:-5px;
  right:-5px;
  min-width:16px;
  height:16px;
  padding:0 4px;
  border-radius:999px;
  background:#ef4444;
  color:#fff;
  font-size:10px;
  font-weight:700;
  line-height:16px;
  text-align:center;
  pointer-events:none;
}
.waiting-prompt__title{
  font-weight:700;
  font-size:13px;
  cursor:grab;
  user-select:none;
  touch-action:none;
}
.waiting-prompt.dragging .waiting-prompt__title{ cursor:grabbing; }
.waiting-prompt__text{
  color:#dbeafe;
  margin-top:2px;
  font-size:12px;
}
body[data-theme="light"] .waiting-prompt__text{
  color:#355a90;
}
.waiting-prompt__actions{
  margin-top:8px;
  display:flex;
  gap:6px;
  flex-wrap:wrap;
}
.waiting-prompt__actions > button{
  white-space:nowrap;
  padding:5px 12px;
  font-size:12px;
  border-radius:8px;
}
body[data-theme="light"] .waiting-prompt .ghost{
  background:#f4f8ff;
  color:#234277;
  border-color:#c7d8f6;
}
@keyframes waitingPulse{
  0%{ box-shadow:0 16px 40px rgba(0,0,0,.45); }
  50%{ box-shadow:0 16px 48px rgba(59,130,246,.35); }
  100%{ box-shadow:0 16px 40px rgba(0,0,0,.45); }
}

/* === DESKTOP STAGE === */
.stage{
  position:relative;
  height:clamp(280px, 54vh, 760px);
  min-height:0;
  padding:10px;
  display:grid;
  place-items:stretch;
  overflow:hidden;
}
.stage .tile{
  position:relative !important;
  inset:auto !important;
  transform:none !important;
  width:100% !important;
  height:100% !important;
  border-width:2px;
  border-color:#3b455f;
  border-radius:14px;
  cursor:default;
  box-shadow:0 10px 30px rgba(0,0,0,.35);
}
.stage .tile::before{ display:none }
.stage .tile .resizer{ display:none }
.stage .tile>video{
  object-fit:contain !important;
  background:#000;
}

/* === Drag & Resize enhancements (v3.4.1) === */
.grid, .stage { position: relative; }
.tile{
  position: absolute; /* override base per drag */
  resize: none;
  overflow: hidden;
  border-radius: 10px;
  background: #0f172a;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
  transition: box-shadow .15s ease, transform .05s linear;
  cursor: grab;
  min-width: 160px;
  min-height: 120px;
}
.tile.dragging { cursor: grabbing; box-shadow: 0 0 16px rgba(255,255,255,0.45); }
.tile.resizing { box-shadow: 0 0 16px rgba(96,165,250,.55); }
.tile video { width:100%; height:100%; object-fit: cover; pointer-events: none; }

/* ==== v3.4.3: 16:9 & share tweaks ==== */
#stage{ position: relative; }
body.has-share #stage{ flex:1 1 0; min-height:0; height:auto; }
#videos{
  position: relative;
  flex:1 1 auto;
  min-height:360px;
  height:100%;
  padding:12px 12px 120px;
  overflow:auto;
}
/* Layout classici (Meet/Zoom) + libero */
#videos.layout-grid{
  display:grid;
  gap:12px;
  grid-template-columns:repeat(var(--grid-cols, 2), minmax(0, 1fr));
  grid-auto-rows:minmax(120px, 1fr); /* tiles fill available height, no overflow */
  overflow:auto;
  padding:12px; /* override base 120px bottom padding */
}
#videos.layout-grid .tile{
  position:relative !important;
  inset:auto !important;
  transform:none !important;
  width:100% !important;
  height:auto !important;
  min-height:0 !important;
  min-width:0 !important;
  box-shadow:0 1px 5px rgba(0,0,0,.3) !important;
  cursor:default;
}
#videos.layout-grid .tile::before{ display:none !important; }
#videos.layout-grid .tile .resizer{ display:none !important; }
#videos.layout-grid[data-count="1"]{ grid-template-columns:1fr; }
/* count=3: 3 colonne uguali */
#videos.layout-grid[data-count="3"]{ grid-template-columns:repeat(3, minmax(0, 1fr)); }
/* count=4: 2 colonne */
#videos.layout-grid[data-count="4"]{ grid-template-columns:repeat(2, minmax(0, 1fr)); }
#videos.layout-grid[data-count="5"],
#videos.layout-grid[data-count="6"]{
  grid-template-columns:repeat(3, minmax(0, 1fr));
}
#videos.layout-grid[data-count="7"],
#videos.layout-grid[data-count="8"],
#videos.layout-grid[data-count="9"]{
  grid-template-columns:repeat(3, minmax(0, 1fr));
}

/* === Layout oratore (solo desktop ≥901px) ===
   Speaker tile = pannello sinistro grande (flex:2.2)
   Sidebar JS = colonna destra scorrevole con tutti gli altri tile
   Le regole sono in @media(min-width:901px) per non sovrascrivere il mobile
*/
@media(min-width:901px){
  #videos.layout-speaker{
    display:flex;
    gap:8px;
    overflow:hidden;
    padding:8px;
  }
  #videos.layout-speaker .tile{
    position:relative !important;
    inset:auto !important;
    transform:none !important;
    min-width:0 !important;
    min-height:0 !important;
    box-shadow:0 1px 5px rgba(0,0,0,.3) !important;
    cursor:default;
  }
  #videos.layout-speaker .tile::before{ display:none !important; }
  #videos.layout-speaker .tile .resizer{ display:none !important; }
  /* Speaker: pannello sinistro, si estende in altezza */
  #videos.layout-speaker > .tile:first-child{
    flex:2.2;
    width:auto !important;
    height:auto !important;
    align-self:stretch;
  }
  /* Sidebar: colonna destra con tile scorrevoli */
  #videos.layout-speaker > .speaker-sidebar{
    flex:1;
    min-width:0;
    display:flex;
    flex-direction:column;
    gap:8px;
    overflow-y:auto;
  }
  /* Tile nella sidebar: mantengono il 16/9 e non si comprimono */
  #videos.layout-speaker .speaker-sidebar .tile{
    flex-shrink:0;
    width:100% !important;
    height:auto !important;
    aspect-ratio:16/9;
  }
  /* count=1: solo speaker, occupa tutto */
  #videos.layout-speaker[data-count="1"] > .tile:first-child{ flex:1; }
  /* count=2: due pannelli uguali */
  #videos.layout-speaker[data-count="2"] > .tile:first-child{ flex:1; }
}

#videos.layout-manual .tile .resizer{ display:block; }
#videos.layout-manual{
  overflow:auto;
  padding-bottom:calc(120px + env(safe-area-inset-bottom));
}
body[data-theme="light"] #videos{
  background:
    radial-gradient(800px 220px at 20% 0%, rgba(123,160,222,.10) 0%, transparent 65%),
    linear-gradient(180deg,#f8fbff 0%, #f3f7ff 100%);
}
.tile[data-autopos="1"]{ width: 320px; height: 180px; } /* 16:9 */
body.has-share .tile.thumb{ height: var(--thumb-h); min-width: 220px; }
body.has-share #videos,
body.has-teacher-layout #videos{
  flex:0 0 auto;
  min-height: calc(var(--thumb-h) + 24px);
  height: calc(var(--thumb-h) + 24px);
  max-height: calc(var(--thumb-h) + 24px);
  padding:12px;
  overflow-x:auto;
  overflow-y:hidden;
  display:flex;
  gap:12px;
  align-items:flex-start;
}
body.has-teacher-layout #videos{
  min-height:96px !important;
  height:auto !important;
  max-height:none !important;
  min-width:0;
  align-self:stretch;
  overflow-x:auto;
  overflow-y:hidden;
  flex-shrink:0;
}
body.has-share #videos .tile.thumb,
body.has-teacher-layout #videos .tile.thumb{
  position:relative !important;
  inset:auto !important;
  transform:none !important;
  flex:0 0 auto;
  width:clamp(220px, 22vw, 320px) !important;
  height:var(--thumb-h) !important;
}
body.has-teacher-layout #videos .tile.thumb{
  width:clamp(160px, 18vw, 240px) !important;
  height:72px !important;
}
body.has-share #videos .tile.thumb > video,
body.has-teacher-layout #videos .tile.thumb > video{
  object-fit: contain !important;
  object-position: center center !important;
  background:#000;
}
body.has-teacher-layout #videos[data-count="0"]{
  display:none;
  min-height:0;
  height:0;
  max-height:0;
  padding:0;
  overflow:hidden;
}
/* Thumbnail strip per teacher layout */
body.has-teacher-layout .tile.thumb{ height: var(--thumb-h); min-width: 220px; }
/* Stage docente: espandi a riempire tutto lo spazio disponibile */
body.has-teacher-layout .screen-panel{
  margin-bottom:0;
  min-height:max(82vh, 520px);
  height:auto;
  flex:none;
}
body.has-teacher-layout #stage {
  flex:1 1 0;
  min-height:max(72vh, 440px);
  height:auto !important;
}
body.has-teacher-layout .stage .tile > video {
  object-fit: contain !important;
  object-position: center center !important;
  background:#000;
}
/* Bottone docente attivo */
#teacherLayoutBtn .ico{
  width: 24px;
  height: 24px;
  transform: translate(0px, 1px);
}

#teacherLayoutBtn.active{
  color: #ef4444;
  background: rgba(239,68,68,.15);
}

body[data-theme="dark"] #teacherLayoutBtn.active{
  color:#ffb7c0;
  background:rgba(239,68,68,.18);
  box-shadow:none;
}
body.has-share.share-focus #stage{
  flex:1 1 0;
  height:auto;
}
body.has-share.share-focus #videos{
  display:none;
}
/* === Modalità espansa + scorrevole === */
body.has-share.share-large .content{
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior-y:contain;
}
body.has-share.share-large .screen-panel{
  flex:none;
  min-height:max(82vh, 520px);
}
body.has-share.share-large #stage{
  flex:1 1 0;
  min-height:max(72vh, 440px);
  height:auto;
}
body.has-share.share-large #videos{
  flex:none;
  height:auto;
  max-height:none;
  min-height:calc(var(--thumb-h) + 24px);
  overflow-x:auto;
  overflow-y:hidden;
}

/* ==== v3.4.4: bottom controls gradient (opzionale) ==== */
#controls, #toolbar, .controls, .bottom-controls {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px 14px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom)); /* safe-area */
  background: linear-gradient(180deg, rgba(15,23,42,0.0) 0%, rgba(15,23,42,0.85) 35%);
  backdrop-filter: blur(6px);
}

/* === Allegati (dropzone + lista) === */
.dropzone{ border:1px dashed var(--border); border-radius:12px; padding:16px; text-align:center; color:var(--muted); background:rgba(11,18,32,.6); outline: none; }
.dropzone.dragover{ border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.25) inset; color:#cfe0ff; }
.attach-item{ display:flex; align-items:center; justify-content:space-between; border:1px solid var(--border); border-radius:10px; padding:8px; background:#0b1220; }
body[data-theme="light"] .dropzone{ background:#f5f8ff; }
body[data-theme="light"] .dropzone.dragover{ color:#1e3a8a; }
body[data-theme="light"] .attach-item{ background:#ffffff; }
.attach-item .meta{ display:grid; gap:4px } .attach-item .actions{ display:flex; gap:6px } .attach-item .name{ font-weight:600; word-break:break-word } .attach-item .size{ color:var(--muted); font-size:12px }

/* === Chat: stile coerente con l'app === */
.sidebar .card .row { align-items: center; margin-top: 10px; }

/* Input chat */
#chat-input {
  flex: 1 1 auto;
  height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
#chat-input::placeholder { color: color-mix(in srgb, var(--text) 45%, transparent); }
#chat-input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
}

/* Bottone "Invia" — stesso stile dei bottoni principali anche senza classe .primary */
.sidebar .card .row > button{
  background: var(--accent);
  border: 1px solid #2b69d9;
  color: #fff;
  border-radius: 12px;
  height: 38px;
  padding: 0 16px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: filter .15s ease, transform .05s ease;
}
.sidebar .card .row > button:hover { filter: brightness(1.1); }
.sidebar .card .row > button:active { transform: translateY(1px); }
.sidebar .card .row > button:disabled { opacity: .6; cursor: not-allowed; }

/* === (1) Evita il "salto" di altezza quando cambia la UI del browser === */
@supports (height: 100dvh) {
  .meet-window{
    height: calc(100dvh - 16px) !important;
  }
  #videos{
    min-height: 360px !important;
  }
}

/* === (2) Prejoin: blocco video con aspect-ratio fisso e altezza limitata === */
.preview{
  aspect-ratio: 16 / 9;
  min-height: 0;
  max-height: clamp(240px, 48vh, 420px); /* un filo più alto */
}
/* .preview video — regola consolidata sopra (riga ~904) */

/* === (3) Dettagli: impedisci al video di influenzare layout anche fuori dal prejoin === */
.tile > video{ display: block; }

/* === MOBILE: layout a riquadri + safe-area === */
@media (max-width:900px){
  body{ padding:0 }
  .meet-window{ width:100%; height:100dvh !important; border-radius:0 }
  .topbar{
    display:grid;
    grid-template-columns:minmax(0,1fr) auto;
    align-items:center;
    gap:6px;
    padding:8px 8px;
  }
  .topbar .left{
    min-width:0;
    display:flex;
    align-items:center;
    gap:6px;
    overflow:hidden;
  }
  .topbar .right{
    display:flex;
    flex-wrap:nowrap;
    align-items:center;
    justify-content:flex-end;
    gap:6px;
  }
  .brand{ font-size:16px; line-height:1.15; }
  .divider{ display:none; }
  .badge{
    white-space:nowrap;
    font-size:11px;
    padding:3px 7px;
  }
  .icon{ inline-size:46px; block-size:46px; border-radius:10px; }

  .content{
    display:flex;
    flex-direction:column;
    height:100%;
    min-height:0;
    overflow:hidden;
  }
  .grid, .stage { position: relative !important; }

  .sidebar{
    left:8px;
    right:8px;
    top:8px;
    bottom:calc(76px + env(safe-area-inset-bottom));
    width:auto;
    height:auto;
    border-radius:16px;
    transform:translateY(calc(100% + 24px));
    transition:transform .24s ease;
  }
  .sidebar.open{
    transform:translateY(0%);
    visibility:visible;
    pointer-events:auto;
  }
  .sidebar__content{ padding-right:0; }

  /* più spazio per il video/stage su mobile */
  #screenPanel{
    margin:8px 8px 0;
    border-radius:14px;
  }
  /* Intestazione screen panel: wrap su schermi stretti */
  .screen-panel__head{
    flex-wrap:wrap;
    gap:4px;
    padding:8px 10px;
  }
  .screen-panel__title{
    font-size:13px;
    font-weight:700;
  }
  .screen-panel__tools{
    flex-wrap:wrap;
    gap:6px;
  }
  .screen-panel__status{
    max-width:100%;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
    font-size:11px;
  }
  #stage{
    padding:8px;
    height:clamp(200px, 38vh, 400px) !important;
    min-height:0 !important;
    max-height:none;
    overflow:hidden;
  }
  /* Stage ridotto in has-share: cresce in flex per riempire lo spazio disponibile */
  body.has-share .screen-panel{ flex:1 1 0; min-height:0; }
  body.has-share #stage{ flex:1 1 0; height:auto !important; min-height:clamp(160px, 34vh, 360px) !important; }
  /* Teacher layout su mobile: stage espanso */
  body.has-teacher-layout #stage{ flex:1 1 0 !important; height:auto !important; min-height:0 !important; }
  /* Focus mode: funziona su mobile (override dell'!important della regola has-share) */
  body.has-share.share-focus #stage{
    flex:1 1 0 !important;
    height:auto !important;
    min-height:0 !important;
  }
  body.has-share.share-focus #videos{
    display:none !important;
  }
  /* Modalità espansa+scorrevole su mobile */
  body.has-share.share-large .content{
    overflow-y:auto !important;
    -webkit-overflow-scrolling:touch;
  }
  body.has-share.share-large .screen-panel{
    flex:none !important;
    min-height:max(78vh, 400px) !important;
  }
  body.has-share.share-large #stage{
    flex:1 1 0 !important;
    height:auto !important;
    min-height:max(65vh, 320px) !important;
  }
  body.has-share.share-large #videos{
    flex:none !important;
    height:auto !important;
    max-height:none !important;
  }
  /* Thumbnail strip più compatta su mobile */
  body.has-share #videos,
  body.has-teacher-layout #videos{
    min-height:116px !important;
    height:116px !important;
    max-height:116px !important;
    padding:8px !important;
    gap:8px !important;
  }
  body.has-share #videos .tile.thumb,
  body.has-share .tile.thumb,
  body.has-teacher-layout #videos .tile.thumb,
  body.has-teacher-layout .tile.thumb{
    width:clamp(120px, 32vw, 180px) !important;
    height:96px !important;
    min-width:120px !important;
  }
  body.has-teacher-layout #videos{
    min-height:88px !important;
    height:auto !important;
    max-height:none !important;
  }
  body.has-teacher-layout .screen-panel{
    flex:none !important;
    min-height:max(78vh, 400px) !important;
  }
  body.has-teacher-layout #stage{
    flex:1 1 0 !important;
    height:auto !important;
    min-height:max(65vh, 320px) !important;
  }
  body.has-teacher-layout #videos .tile.thumb,
  body.has-teacher-layout .tile.thumb{
    width:clamp(108px, 26vw, 148px) !important;
    height:72px !important;
    min-width:108px !important;
  }
  body.has-teacher-layout #videos[data-count="0"]{
    display:none !important;
    min-height:0 !important;
    height:0 !important;
    max-height:0 !important;
    padding:0 !important;
    overflow:hidden !important;
  }
  body.has-teacher-layout .content{
    grid-template-rows:minmax(0, 1fr) 88px;
    overflow-y:auto;
    overflow-x:hidden;
  }
  body.has-teacher-layout .content:has(#videos[data-count="0"]){
    grid-template-rows:minmax(0, 1fr) 0;
  }

  #videos{
    position: relative;
    flex:1 1 auto;
    gap: 8px;
    padding: 8px 8px calc(96px + env(safe-area-inset-bottom));
    min-height: 0 !important;
    max-height: 100%;
    overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain;
  }
  #videos.layout-grid,
  #videos.layout-speaker{
    display:grid;
    gap:10px;
  }
  #videos.layout-grid{ grid-template-columns:1fr; }
  #videos.layout-grid{
    grid-template-columns:repeat(var(--m-grid-cols, 1), minmax(0, 1fr));
  }
  #videos.layout-grid .tile{
    min-height:var(--m-grid-min-h, 160px);
  }
  #videos.layout-grid[data-count="1"] .tile{
    min-height:clamp(250px, 44vh, 430px);
    aspect-ratio:16 / 9;
  }
  #videos.layout-grid[data-count="2"] .tile{
    min-height:clamp(210px, 34vh, 340px);
  }
  #videos.layout-grid[data-count="3"],
  #videos.layout-grid[data-count="4"],
  #videos.layout-grid[data-count="5"],
  #videos.layout-grid[data-count="6"],
  #videos.layout-grid[data-count="7"],
  #videos.layout-grid[data-count="8"]{
    grid-template-columns:repeat(2, minmax(0, 1fr));
  }
  #videos.layout-grid[data-count="3"] .tile:first-child{
    grid-column:1 / -1;
    min-height:clamp(220px, 36vh, 360px);
  }
  #videos.layout-grid[data-count="3"] .tile:not(:first-child){
    min-height:clamp(160px, 24vh, 250px);
  }
  #videos.layout-grid[data-count="4"] .tile,
  #videos.layout-grid[data-count="5"] .tile,
  #videos.layout-grid[data-count="6"] .tile,
  #videos.layout-grid[data-count="7"] .tile,
  #videos.layout-grid[data-count="8"] .tile{
    min-height:clamp(145px, 21vh, 220px);
    aspect-ratio:16 / 11;
  }

  /* Mobile speaker: speaker grande sopra, laterali 2 per riga sotto */
  #videos.layout-speaker{
    grid-template-columns:1fr 1fr;
    grid-template-rows:auto;
    overflow-y:auto;
    padding:8px 8px calc(96px + env(safe-area-inset-bottom));
  }
  /* Speaker: larghezza piena, grande */
  #videos.layout-speaker:not([data-dense="1"]) .tile:first-child{
    grid-column:1 / -1 !important;
    grid-row:auto !important;
    aspect-ratio:16/9;
    min-height:clamp(180px,36vh,360px);
  }
  /* Laterali: 2 per riga, piccoli */
  #videos.layout-speaker:not([data-dense="1"]) .tile:not(:first-child){
    grid-column:auto !important;
    grid-row:auto !important;
    aspect-ratio:16/9;
    min-height:clamp(90px,14vh,160px);
  }
  /* count=2: tile laterale anche full width */
  #videos.layout-speaker[data-count="2"]:not([data-dense="1"]) .tile:not(:first-child){
    grid-column:1 / -1 !important;
    min-height:clamp(130px,22vh,240px);
  }
  /* Dense (4+ su mobile): griglia 2 colonne uniforme */
  #videos.layout-speaker[data-dense="1"]{
    grid-template-columns:repeat(var(--m-grid-cols,2),minmax(0,1fr));
  }
  #videos.layout-speaker[data-dense="1"] .tile:first-child,
  #videos.layout-speaker[data-dense="1"] .tile:not(:first-child){
    grid-column:auto !important;
    grid-row:auto !important;
    aspect-ratio:16/9;
    min-height:clamp(100px,15vh,180px);
  }

  #videos.layout-grid .tile,
  #videos.layout-speaker .tile{
    position:relative !important;
    inset:auto !important;
    transform:none !important;
    width:100% !important;
    min-width:0 !important;
    resize:none !important;
    cursor:default !important;
    border-radius:14px;
    background:#000;
    box-shadow:0 2px 10px rgba(0,0,0,.3);
    overflow:hidden;
    /* height gestita dalle regole specifiche per layout */
  }
  #videos.layout-grid .tile .resizer,
  #videos.layout-speaker .tile .resizer{ display:none !important; }

  #videos.layout-manual .tile{
    position: absolute !important;
    inset: auto !important;
    min-width: 120px !important;
    min-height: 90px !important;
    resize: none !important;
    cursor: grab !important;
    touch-action: none;
    border-radius: 14px; background:#000;
    box-shadow: 0 2px 10px rgba(0,0,0,.3); overflow:hidden;
  }
  #videos.layout-manual .tile > video{
    object-fit: contain !important;
    background:#000;
  }
  #videos.layout-manual .tile.dragging{ cursor:grabbing !important; }
  #videos.layout-manual .tile .resizer{
    width:18px;
    height:18px;
    right:5px;
    bottom:5px;
    touch-action:none;
  }
  .tile::before{ display:none !important; }
  .tile>video{
    width:100% !important; height:100% !important;
    object-fit:cover !important; object-position:center !important;
  }

  /* barra in basso su mobile con safe-area */
  .bottombar{
    border-top:1px solid var(--border);
    display:flex;
    flex-wrap:nowrap;
    align-items:center;
    justify-content:center;
    gap:4px;
    padding:8px 6px;
    padding-left: max(6px, env(safe-area-inset-left));
    padding-right: max(6px, env(safe-area-inset-right));
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    overflow:hidden;
  }
  .bottombar .icon{
    flex:0 0 auto;
    inline-size:40px;
    block-size:40px;
    border-radius:11px;
  }
  .bottombar .icon .ico,
  .bottombar .icon svg{
    width:20px;
    height:20px;
  }
  @media (max-width:360px){
    .bottombar{
      gap:3px;
      padding-left:max(4px, env(safe-area-inset-left));
      padding-right:max(4px, env(safe-area-inset-right));
    }
    .bottombar .icon{
      inline-size:38px;
      block-size:38px;
      border-radius:10px;
    }
  }
  .waiting-prompt{
    left:8px;
    right:8px;
    width:auto;
    top:10px;
    padding:8px 10px;
    border-radius:10px;
  }
  .waiting-prompt__title{ font-size:12px; }
  .waiting-prompt__text{ font-size:11px; }
  .waiting-prompt__actions{
    margin-top:6px;
    flex-direction:row;
    flex-wrap:wrap;
    gap:5px;
  }
  .waiting-prompt__actions > button{
    flex:1;
    min-width:0;
    padding:4px 8px;
    font-size:11px;
  }
  .waiting-actions{
    grid-template-columns:1fr;
  }
}

@media (min-width:768px) and (max-width:1024px){
  #sidebar{
    left:auto;
    right:12px;
    top:12px;
    bottom:12px;
    width:clamp(320px, 36vw, 420px);
    height:auto;
    transform:translateX(110%);
    transition:transform .25s ease;
  }

  #sidebar.open{
    transform:translateX(0%);
  }
}

/* Allineamento coerente del bottone REC */
#recBtn {
  display: flex !important;
  align-items: center;
  justify-content: center;
  transition: background-color .2s ease, transform .1s ease;
}

/* Leggera animazione di pressione */
#recBtn:active {
  transform: scale(0.94);
}

/* Stato visivo quando la registrazione è attiva */
#recBtn.recording {
  background-color: #dc2626 !important;
  border-color: #b91c1c !important;
  color: #fff !important;
  animation: recBtnPulse 1.4s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(220,38,38,.5);
}
@keyframes recBtnPulse {
  0%   { box-shadow: 0 0 0 0 rgba(220,38,38,.45); }
  60%  { box-shadow: 0 0 0 8px rgba(220,38,38,0); }
  100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); }
}

#rec-indicator.recording-live {
  display: inline-flex;
  color: #dc2626;
  border-color: rgba(220,38,38,.14);
  background: rgba(255,255,255,.92);
  box-shadow: 0 8px 24px rgba(220,38,38,.08);
  animation: recTextPulse 1.1s ease-in-out infinite;
}

#rec-indicator.recording-live .ico {
  color: #ef4444;
  animation: recDotPulse 1.1s ease-in-out infinite;
  transform-origin: center;
}

@keyframes recTextPulse {
  0%, 100% {
    opacity: 1;
    color: #dc2626;
  }
  50% {
    opacity: .76;
    color: #f87171;
  }
}

@keyframes recDotPulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
    color: #ef4444;
  }
  50% {
    opacity: .72;
    transform: scale(.86);
    color: #f87171;
  }
}

/* =========================================
   2026 UI Refresh — Bold cinematic redesign
   ========================================= */
:root{
  --bg:#050a14;
  --bg-layer-1:#102642;
  --bg-layer-2:#163462;
  --surface:#0b1322cc;
  --surface-strong:#0d182b;
  --surface-soft:#12213a;
  --line:#24395f;
  --line-strong:#34507f;
  --txt:#eaf2ff;
  --txt-soft:#9fb6d9;
  --brand:#43b0ff;
  --brand-2:#6be7d8;
  --ok:#27d99e;
  --warn:#f7b84b;
  --danger:#ff6f7a;
  --radius-xl:26px;
  --radius-lg:18px;
  --radius-md:14px;
  --shadow-lg:0 36px 90px rgba(1,4,11,.55);
  --shadow-md:0 20px 42px rgba(3,9,20,.42);
}

body[data-theme="light"]{
  --bg:#e8f0fb;
  --bg-layer-1:#d8e7ff;
  --bg-layer-2:#d7fff4;
  --surface:#ffffffd1;
  --surface-strong:#ffffff;
  --surface-soft:#f2f7ff;
  --line:#cad9ef;
  --line-strong:#a8c2e8;
  --txt:#172946;
  --txt-soft:#5d759b;
  --brand:#1763ff;
  --brand-2:#04a9b2;
  --ok:#0e9f6f;
  --warn:#cc7e13;
  --danger:#dc3c5f;
  --shadow-lg:0 30px 80px rgba(23,46,87,.22);
  --shadow-md:0 15px 30px rgba(35,60,104,.16);
}

html, body{
  font-family:'Space Grotesk', system-ui, -apple-system, sans-serif;
}

body{
  background:
    radial-gradient(1400px 760px at -8% -12%, var(--bg-layer-1), transparent 58%),
    radial-gradient(1250px 700px at 108% -8%, var(--bg-layer-2), transparent 56%),
    linear-gradient(155deg, #060b15, var(--bg));
  color:var(--txt);
  letter-spacing:.01em;
}

.meet-window{
  border-radius:var(--radius-xl);
  border:1px solid color-mix(in srgb, var(--line), transparent 30%);
  background:
    linear-gradient(160deg, color-mix(in srgb,var(--surface-strong),#0b1324 18%), color-mix(in srgb,var(--surface-strong),#11203b 34%));
  box-shadow:var(--shadow-lg);
  backdrop-filter:blur(10px);
}

.topbar{
  border-bottom:1px solid color-mix(in srgb, var(--line), transparent 24%);
  background:
    linear-gradient(180deg, color-mix(in srgb,var(--surface-soft),#ffffff 2%), color-mix(in srgb,var(--surface-strong),#000 3%));
  padding:14px 18px;
}

.brand{
  font-family:'Sora', 'Space Grotesk', sans-serif;
  font-size:clamp(1rem, 1.2vw, 1.22rem);
  font-weight:800;
  letter-spacing:.02em;
}

.badge,
.pill,
.link{
  border-color:color-mix(in srgb, var(--line), transparent 14%);
  color:var(--txt-soft);
  background:color-mix(in srgb, var(--surface-soft), transparent 25%);
}

.icon,
button.primary,
button.ghost,
#sendMsgBtn,
#joinBtn,
#cancelBtn,
#confirmRecordTargetsBtn,
#confirmRecordPassBtn,
#recordTargetsAllBtn,
#recordTargetsNoneBtn,
#cancelRecordTargetsBtn,
#cancelRecordPassBtn{
  border-radius:12px;
  transition:transform .18s ease, box-shadow .24s ease, border-color .18s ease, background .2s ease, color .2s ease;
}

.icon{
  border-color:color-mix(in srgb,var(--line), transparent 14%);
  background:color-mix(in srgb,var(--surface-soft),#0a1323 28%);
  color:var(--txt);
}

.icon:hover,
button.primary:hover,
button.ghost:hover,
#sendMsgBtn:hover,
#joinBtn:hover,
#cancelBtn:hover,
#confirmRecordTargetsBtn:hover,
#confirmRecordPassBtn:hover,
#recordTargetsAllBtn:hover,
#recordTargetsNoneBtn:hover,
#cancelRecordTargetsBtn:hover,
#cancelRecordPassBtn:hover{
  transform:translateY(-1px);
  box-shadow:var(--shadow-md);
}

button.primary,
#joinBtn,
#sendMsgBtn,
#confirmRecordTargetsBtn,
#confirmRecordPassBtn{
  color:#f5fbff;
  border:1px solid color-mix(in srgb,var(--brand), #000 20%);
  background:linear-gradient(135deg, var(--brand), color-mix(in srgb,var(--brand-2), var(--brand) 38%));
  font-weight:700;
}

button.ghost,
#cancelBtn,
#recordTargetsAllBtn,
#recordTargetsNoneBtn,
#cancelRecordTargetsBtn,
#cancelRecordPassBtn,
#screenFocusBtn,
#layoutModeBtn,
#themeToggleBtn{
  color:var(--txt-soft);
  border:1px solid color-mix(in srgb,var(--line), transparent 15%);
  background:color-mix(in srgb,var(--surface-soft),transparent 16%);
}

.content{
  padding:12px;
  gap:12px;
}

.sidebar{
  border-radius:var(--radius-lg);
  border:1px solid color-mix(in srgb,var(--line), transparent 10%);
  background:linear-gradient(180deg, color-mix(in srgb,var(--surface-strong), #02060f 10%), color-mix(in srgb,var(--surface-soft), #02060f 18%));
  box-shadow:var(--shadow-md);
}

.sidebar__header h3{
  font-family:'Sora', 'Space Grotesk', sans-serif;
  font-size:1rem;
  letter-spacing:.03em;
}

.card{
  border-radius:var(--radius-md);
  border:1px solid color-mix(in srgb,var(--line), transparent 14%);
  background:
    linear-gradient(165deg, color-mix(in srgb,var(--surface-strong), #0a1628 8%), color-mix(in srgb,var(--surface-soft), #061121 16%));
  box-shadow:inset 0 1px 0 color-mix(in srgb, #fff, transparent 94%);
}

.card h4{
  color:var(--txt);
  font-family:'Sora', 'Space Grotesk', sans-serif;
  font-weight:700;
}

#chat-log,
.chatlog,
#chat-input,
#username,
#recordPassInput,
#replyInput,
.dev-pick,
#recordTargetsList,
#dropzone,
#previewContent{
  border-radius:12px;
  border:1px solid color-mix(in srgb,var(--line), transparent 16%);
  background:color-mix(in srgb,var(--surface-soft), #050b15 20%);
  color:var(--txt);
}

#chat-input,
#username,
#recordPassInput,
.dev-pick{
  min-height:44px;
  padding:10px 12px;
}

#chat-input::placeholder,
#username::placeholder,
#recordPassInput::placeholder{
  color:color-mix(in srgb, var(--txt-soft), transparent 18%);
}

#videos{
  background:
    linear-gradient(180deg, color-mix(in srgb,var(--surface-soft), #040811 22%), color-mix(in srgb,var(--surface-strong), #01040b 18%));
  border:1px solid color-mix(in srgb,var(--line), transparent 30%);
  border-radius:20px;
  padding:12px;
}

.tile{
  border-radius:16px;
  border:1px solid color-mix(in srgb,var(--line-strong), transparent 22%);
  box-shadow:0 16px 34px rgba(0,0,0,.28);
}

.tile video{
  filter:saturate(1.06) contrast(1.03);
}

.tile .label{
  background:linear-gradient(130deg, rgba(4,10,20,.8), rgba(13,24,43,.6));
  border:1px solid rgba(162,196,255,.28);
  color:#e8f4ff;
  font-size:12px;
  font-weight:600;
  border-radius:10px;
  backdrop-filter:blur(8px);
}

.screen-panel{
  border-radius:16px;
  border:1px solid color-mix(in srgb,var(--line), transparent 14%);
  background:linear-gradient(180deg, color-mix(in srgb,var(--surface-soft), #030813 16%), color-mix(in srgb,var(--surface-strong), #040b15 22%));
}

#stage{
  border-radius:14px;
}

.bottombar{
  border-top:1px solid color-mix(in srgb,var(--line), transparent 20%);
  background:linear-gradient(180deg, color-mix(in srgb,var(--surface-strong), #09121f 8%), color-mix(in srgb,var(--surface-soft), #09111f 20%));
  padding:12px max(14px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  gap:8px;
}

.bottombar .icon{
  flex:1;
  min-height:50px;
  border-radius:14px;
}

#leaveBtn{
  border-color:color-mix(in srgb,var(--danger), transparent 44%);
  background:color-mix(in srgb,var(--danger), transparent 84%);
  color:#ffd7dc;
}

.modal{
  backdrop-filter:blur(8px);
  background:rgba(5,10,18,.5);
}

.modal__panel{
  border-radius:20px;
  border:1px solid color-mix(in srgb,var(--line), transparent 12%);
  background:linear-gradient(165deg, color-mix(in srgb,var(--surface-strong), #0a1425 8%), color-mix(in srgb,var(--surface-soft), #081326 18%));
  box-shadow:var(--shadow-lg);
}

/* #prejoin panel overrides now in the NUOVO PANNELLO PREJOIN section below */

.entry-mode-btn{
  border-radius:10px;
  font-weight:700;
}

.entry-mode-btn.is-active{
  color:#fff;
  background:linear-gradient(135deg, var(--brand), color-mix(in srgb,var(--brand-2), var(--brand) 45%));
}

.tile-ctx-menu{
  border-radius:12px;
  border:1px solid color-mix(in srgb,var(--line), transparent 10%);
  background:color-mix(in srgb,var(--surface-strong), #050913 18%);
  box-shadow:var(--shadow-md);
}

.tile-ctx-item{
  color:var(--txt);
}

.tile-ctx-item:hover{
  background:color-mix(in srgb,var(--surface-soft), transparent 10%);
}

#waitingOverlay,
#waitingPrompt,
#waitingCard,
#waitingMiniBadge,
#notifyBellBtn{
  display:none !important;
}

@media (max-width: 980px){
  .meet-window{
    width:100vw;
    height:100dvh;
    border-radius:0;
    border-inline:none;
  }

  .topbar{
    padding:10px;
  }

  .brand{
    font-size:15px;
  }

  .content{
    padding:8px;
  }

  #videos{
    border-radius:16px;
    padding:8px;
  }

  .sidebar{
    right:8px;
    left:8px;
    width:auto;
    top:8px;
    bottom:86px;
  }
}

@keyframes appFadeLift{
  from{ opacity:0; transform:translateY(8px); }
  to{ opacity:1; transform:translateY(0); }
}

.topbar,
#videos,
.sidebar,
.bottombar{
  animation:appFadeLift .35s ease both;
}

#hostDashBtn{
  cursor:pointer;
}

.admin-panel{
  width:min(1080px, calc(100vw - 32px));
  z-index:60;
}

.admin-panel__content{
  padding-right:0;
}

.admin-panel__frame{
  width:100%;
  min-height:min(860px, calc(100dvh - 140px));
  border:none;
  border-radius:0;
  background:transparent;
}

@media (max-width:980px){
  .admin-panel{
    width:auto;
    right:8px;
    left:8px;
    top:8px;
    bottom:8px;
  }

  .admin-panel__frame{
    min-height:calc(100dvh - 150px);
  }
}

/* =========================================
   Classic WebRTC UI (Meet/Zoom inspired)
   ========================================= */
:root{
  --classic-bg:#0f172a;
  --classic-surface:#111827;
  --classic-surface-2:#0b1322;
  --classic-line:#24334f;
  --classic-text:#e7eefc;
  --classic-muted:#9db0cf;
  --classic-primary:#3b82f6;
  --classic-danger:#ef4444;
  --classic-ok:#22c55e;
}

body[data-theme="dark"]{
  background:#0b1220;
  color:var(--classic-text);
  font-family:'Space Grotesk',system-ui,-apple-system,sans-serif;
}

.meet-window{
  position:relative;
  width:min(1680px, calc(100vw - 20px));
  height:calc(100dvh - 20px);
  border-radius:16px;
  border:1px solid var(--classic-line);
  background:var(--classic-surface);
  box-shadow:0 24px 52px rgba(0,0,0,.45);
}

.topbar{
  background:var(--classic-surface);
  border-bottom:1px solid var(--classic-line);
  padding:10px 14px;
}

.brand{
  font-family:'Sora','Space Grotesk',sans-serif;
  font-size:16px;
  font-weight:700;
  color:#f0f5ff;
}

.badge,
.pill,
.link{
  background:#0c1529;
  border:1px solid var(--classic-line);
  color:var(--classic-muted);
}

.content{
  padding:10px;
  min-height:0;
}

#videos{
  border:1px solid var(--classic-line);
  border-radius:12px;
  background:var(--classic-surface-2);
  padding:10px;
}

.screen-panel{
  border:1px solid var(--classic-line);
  border-radius:12px;
  background:#0c1528;
}

.tile{
  border:1px solid #2e4468;
  border-radius:12px;
  box-shadow:0 8px 20px rgba(0,0,0,.35);
}

.tile .label{
  background:rgba(10,18,33,.76);
  border:1px solid rgba(177,197,231,.28);
  border-radius:8px;
  font-weight:600;
}

.sidebar{
  border-radius:12px;
  border:1px solid var(--classic-line);
  background:#0d172b;
}

.card{
  background:#0f1a31;
  border:1px solid var(--classic-line);
  border-radius:10px;
}

.card h4{
  color:#dce8ff;
  font-size:13px;
  letter-spacing:.02em;
}

#chat-log,
.chatlog,
#chat-input,
#username,
#recordPassInput,
#dropzone,
.dev-pick{
  border-radius:10px;
  border:1px solid var(--classic-line);
  background:#0a1324;
  color:#e8f0ff;
}

#chat-input::placeholder,
#username::placeholder,
#recordPassInput::placeholder{
  color:#9fb1cd;
}

.icon{
  width:42px;
  height:42px;
  border-radius:10px;
  border:1px solid #31486e;
  background:#12203b;
  color:#dbe8ff;
}

.icon:hover{
  background:#1a2b4d;
}

/* Pulsantiera classica, completa e leggibile */
.bottombar{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  border-top:1px solid var(--classic-line);
  background:#0e182d;
  padding:10px 14px calc(10px + env(safe-area-inset-bottom));
  overflow-x:auto;
  scrollbar-width:none;
}

.bottombar::-webkit-scrollbar{
  display:none;
}

.bottombar .icon{
  flex:0 0 auto;
  width:54px;
  height:54px;
  border-radius:50%;
  border:1px solid #3a527d;
  background:#182846;
  color:#e6efff;
}

.bottombar .icon .ico{
  width:22px;
  height:22px;
}

.bottombar .icon:hover{
  transform:translateY(-1px);
  background:#22365c;
}

#leaveBtn{
  border-color:#b93843 !important;
  background:#8f1f2a !important;
  color:#ffe7ea !important;
}

#leaveBtn:hover{
  background:#a82634 !important;
}

.icon.active{
  background:#1f3f76;
  border-color:#5f98ff;
  color:#eaf3ff;
}

.icon.danger{
  background:#7f1f2a;
  border-color:#b93843;
  color:#ffe4e7;
}

@media (max-width:980px){
  .meet-window{
    width:100vw;
    height:100dvh;
    border-radius:0;
    border:none;
  }

  .topbar{
    padding:9px 10px;
  }

  .content{
    padding:8px;
  }

  .bottombar{
    justify-content:center;
    padding-left:10px;
    padding-right:10px;
  }

  .bottombar .icon{
    width:52px;
    height:52px;
  }
}

/* =========================================
   Light Default + Borderless Refinement
   ========================================= */
body{
  background:#f2f5fb;
  color:#1e2f4f;
}

.meet-window{
  background:#ffffff;
  border:none;
  box-shadow:0 16px 36px rgba(26,47,87,.14);
}

.topbar{
  background:#ffffff;
  border-bottom:none;
}

#videos{
  background:#eef3fb;
  border:none;
}

.screen-panel,
.sidebar,
.card,
#chat-log,
.chatlog,
#chat-input,
#username,
#recordPassInput,
#dropzone,
.dev-pick,
.admin-panel__frame,
.icon,
.badge,
.pill,
.link,
.tile,
.tile .label,
.bottombar{
  border:none !important;
}

.screen-panel,
.sidebar,
.card,
.bottombar{
  background:#ffffff;
}

.icon{
  background:#e6edf8;
  color:#253d63;
}

.icon:hover{
  background:#dbe6f6;
}

.bottombar{
  background:#ffffff;
  box-shadow:0 -4px 10px rgba(15,30,60,.04);
}

.bottombar .icon{
  background:#e6edf8;
}

#leaveBtn{
  background:#c63444 !important;
  color:#fff3f5 !important;
}

body[data-theme="dark"]{
  background:#0b1220;
  color:#e7eefc;
}

body[data-theme="dark"] .meet-window,
body[data-theme="dark"] .topbar,
body[data-theme="dark"] .screen-panel,
body[data-theme="dark"] .sidebar,
body[data-theme="dark"] .card,
body[data-theme="dark"] .bottombar{
  background:#111827;
}

body[data-theme="dark"] #videos{
  background:#0b1322;
}

body[data-theme="dark"] .icon,
body[data-theme="dark"] .bottombar .icon{
  background:#182846;
  color:#e6efff;
}

/* =========================================
   Theme Rebuild v2 (clean light + clean dark)
   ========================================= */
body[data-theme="light"]{
  --app-bg:#f2f2f2;
  --app-text:#1a1a1a;
  --app-muted:#777;
  --app-surface:#ffffff;
  --app-surface-soft:#f5f5f5;
  --app-control:rgba(15,23,42,.022);
  --app-control-hover:rgba(15,23,42,.04);
  --app-control-active:color-mix(in srgb, var(--app-primary), #fff 80%);
  --app-primary:#2d6df8;
  --app-danger:#c83545;
  --app-tile:#e8e8e8;
}

body[data-theme="dark"]{
  --app-bg:#0b1220;
  --app-text:#e7eefc;
  --app-muted:#9db0cf;
  --app-surface:#111827;
  --app-surface-soft:#0f1a31;
  --surface-2:#0b1220;
  --panel:#0f1a2e;
  --panel-2:#152038;
  --app-control:#1a2a47;
  --app-control-hover:#223a63;
  --app-primary:#4b8dff;
  --app-danger:#a82634;
  --app-tile:#182846;
}
body[data-theme="dark"]{
  background:var(--app-bg) !important;
  color:var(--app-text) !important;
}

body[data-theme="light"] .meet-window,
body[data-theme="dark"] .meet-window{
  background:var(--app-surface) !important;
  border:none !important;
  box-shadow:0 10px 24px rgba(18,34,66,.10);
}

body[data-theme="dark"] .meet-window{
  box-shadow:0 20px 46px rgba(0,0,0,.42);
}

body[data-theme="light"] .topbar,
body[data-theme="dark"] .topbar,
body[data-theme="light"] .sidebar,
body[data-theme="dark"] .sidebar,
body[data-theme="light"] .screen-panel,
body[data-theme="dark"] .screen-panel,
body[data-theme="light"] .card,
body[data-theme="dark"] .card,
body[data-theme="light"] .bottombar,
body[data-theme="dark"] .bottombar,
body[data-theme="light"] #chat-log,
body[data-theme="dark"] #chat-log,
body[data-theme="light"] .chatlog,
body[data-theme="dark"] .chatlog,
body[data-theme="light"] #chat-input,
body[data-theme="dark"] #chat-input,
body[data-theme="light"] #username,
body[data-theme="dark"] #username,
body[data-theme="light"] #recordPassInput,
body[data-theme="dark"] #recordPassInput,
body[data-theme="light"] #dropzone,
body[data-theme="dark"] #dropzone,
body[data-theme="light"] .dev-pick,
body[data-theme="dark"] .dev-pick,
body[data-theme="light"] .admin-panel__frame,
body[data-theme="dark"] .admin-panel__frame,
body[data-theme="light"] .icon,
body[data-theme="dark"] .icon,
body[data-theme="light"] .badge,
body[data-theme="dark"] .badge,
body[data-theme="light"] .pill,
body[data-theme="dark"] .pill,
body[data-theme="light"] .link,
body[data-theme="dark"] .link,
body[data-theme="light"] .tile,
body[data-theme="dark"] .tile,
body[data-theme="light"] .tile .label,
body[data-theme="dark"] .tile .label,
body[data-theme="light"] #videos,
body[data-theme="dark"] #videos{
  border:none !important;
}

body[data-theme="light"] #videos,
body[data-theme="dark"] #videos{
  background:var(--app-surface-soft) !important;
}

body[data-theme="light"] .topbar,
body[data-theme="dark"] .topbar,
body[data-theme="light"] .sidebar,
body[data-theme="dark"] .sidebar,
body[data-theme="light"] .screen-panel,
body[data-theme="dark"] .screen-panel,
body[data-theme="light"] .card,
body[data-theme="dark"] .card,
body[data-theme="light"] .bottombar,
body[data-theme="dark"] .bottombar,
body[data-theme="light"] #chat-log,
body[data-theme="dark"] #chat-log,
body[data-theme="light"] .chatlog,
body[data-theme="dark"] .chatlog,
body[data-theme="light"] #chat-input,
body[data-theme="dark"] #chat-input,
body[data-theme="light"] #username,
body[data-theme="dark"] #username,
body[data-theme="light"] #recordPassInput,
body[data-theme="dark"] #recordPassInput,
body[data-theme="light"] #dropzone,
body[data-theme="dark"] #dropzone,
body[data-theme="light"] .dev-pick,
body[data-theme="dark"] .dev-pick,
body[data-theme="light"] .admin-panel__frame,
body[data-theme="dark"] .admin-panel__frame,
body[data-theme="light"] .tile .label,
body[data-theme="dark"] .tile .label,
body[data-theme="light"] .badge,
body[data-theme="dark"] .badge,
body[data-theme="light"] .pill,
body[data-theme="dark"] .pill,
body[data-theme="light"] .link,
body[data-theme="dark"] .link{
  background:var(--app-surface) !important;
  color:var(--app-text) !important;
}

body[data-theme="light"] .badge,
body[data-theme="light"] .pill,
body[data-theme="light"] .link,
body[data-theme="dark"] .badge,
body[data-theme="dark"] .pill,
body[data-theme="dark"] .link,
body[data-theme="light"] .hint,
body[data-theme="dark"] .hint,
body[data-theme="light"] .screen-panel__status,
body[data-theme="dark"] .screen-panel__status,
body[data-theme="light"] .label,
body[data-theme="dark"] .label{
  color:var(--app-muted) !important;
}

body[data-theme="light"] .icon,
body[data-theme="dark"] .icon,
body[data-theme="light"] .bottombar .icon,
body[data-theme="dark"] .bottombar .icon{
  background:var(--app-control) !important;
  color:var(--app-text) !important;
}

body[data-theme="light"] .topbar .icon{
  inline-size:46px;
  block-size:46px;
  box-shadow:none !important;
  filter:none !important;
}

body[data-theme="dark"] .topbar .icon{
  inline-size:46px;
  block-size:46px;
  box-shadow:none !important;
  filter:none !important;
}

body[data-theme="light"] .icon:hover,
body[data-theme="dark"] .icon:hover,
body[data-theme="light"] .bottombar .icon:hover,
body[data-theme="dark"] .bottombar .icon:hover{
  background:var(--app-control-hover) !important;
}

body[data-theme="light"] .icon.active,
body[data-theme="dark"] .icon.active{
  background:color-mix(in srgb,var(--app-primary), #fff 72%) !important;
  color:var(--app-primary) !important;
}

body[data-theme="light"] .icon.active,
body[data-theme="light"] .bottombar .icon.active{
  background:var(--app-control-active) !important;
  color:var(--app-primary) !important;
  box-shadow:none !important;
}

body[data-theme="light"] .topbar .icon.active{
  background:color-mix(in srgb, var(--app-primary), #fff 76%) !important;
  color:var(--app-primary) !important;
}

body[data-theme="dark"] .icon.active{
  background:color-mix(in srgb,var(--app-primary), #000 62%) !important;
  color:#dcebff !important;
}

body[data-theme="dark"] .topbar .icon.active{
  background:color-mix(in srgb, var(--app-primary), #0b1220 58%) !important;
  color:#dcebff !important;
  box-shadow:none !important;
}

body[data-theme="light"] .icon.danger,
body[data-theme="light"] .bottombar .icon.danger,
body[data-theme="dark"] .icon.danger,
body[data-theme="dark"] .bottombar .icon.danger{
  color:var(--app-danger) !important;
}

body[data-theme="light"] #leaveBtn,
body[data-theme="dark"] #leaveBtn{
  background:var(--app-danger) !important;
  color:#fff !important;
}

body[data-theme="light"] #chat-input::placeholder,
body[data-theme="dark"] #chat-input::placeholder,
body[data-theme="light"] #username::placeholder,
body[data-theme="dark"] #username::placeholder,
body[data-theme="light"] #recordPassInput::placeholder,
body[data-theme="dark"] #recordPassInput::placeholder{
  color:color-mix(in srgb, var(--app-muted), transparent 8%) !important;
}

body[data-theme="light"] .tile,
body[data-theme="dark"] .tile{
  background:var(--app-tile) !important;
}

body[data-theme="light"] .brand,
body[data-theme="dark"] .brand,
body[data-theme="light"] .card h4,
body[data-theme="dark"] .card h4,
body[data-theme="light"] .screen-panel__title,
body[data-theme="dark"] .screen-panel__title{
  color:var(--app-text) !important;
}

/* Reintroduce subtle borders where useful (chat + menu panels) */
body[data-theme="light"] .sidebar{
  border:1px solid #dbe4f2 !important;
}
body[data-theme="dark"] .sidebar{
  border:1px solid #23324c !important;
}

body[data-theme="light"] #chat-log,
body[data-theme="light"] .chatlog,
body[data-theme="light"] #chat-input{
  border:1px solid #d7e1f0 !important;
}

body[data-theme="dark"] #chat-log,
body[data-theme="dark"] .chatlog,
body[data-theme="dark"] #chat-input{
  border:1px solid #2a3b58 !important;
}

body[data-theme="light"] #sidebar .card{
  border:1px solid #dbe4f2 !important;
}

body[data-theme="dark"] #sidebar .card{
  border:1px solid #24354f !important;
}

/* Fine-tune visual centering for leave icon */
#leaveBtn .ico{
  transform:translateX(1px);
}

/* =========================================
   Hamburger UX v2 (Meet-inspired)
   ========================================= */
#sidebar{
  width:clamp(330px, 32vw, 430px);
  border-radius:14px;
  box-shadow:0 16px 34px rgba(15,24,42,.22);
}

#sidebar .sidebar__header{
  position:sticky;
  top:0;
  z-index:2;
  margin:-2px -2px 4px;
  padding:12px 14px;
  border-radius:12px 12px 0 0;
  background:var(--app-surface);
}

#sidebar .sidebar__header h3{
  font-family:'Sora','Space Grotesk',sans-serif;
  font-size:14px;
  letter-spacing:.02em;
}

#sidebar .sidebar__content{
  display:grid;
  gap:12px;
  padding:2px 4px 10px 0;
}

#adminPanel{
  box-shadow:0 18px 44px rgba(15,24,42,.18);
  gap:8px;
}

#adminPanel .sidebar__header{
  position:relative;
  top:auto;
  z-index:2;
  margin:0;
  padding:2px 2px 6px;
  min-height:auto;
  border-bottom:none;
  background:transparent;
}

#adminPanel .sidebar__content{
  flex:1 1 auto;
  min-height:0;
  height:100%;
  display:block;
  overflow:hidden;
  padding:0;
}

#adminPanel .admin-panel__frame{
  display:block;
  width:100%;
  height:100%;
  min-height:0;
  border:none !important;
  border-radius:0;
  background:transparent !important;
  box-shadow:none;
}

#sidebar .card{
  border-radius:12px;
  padding:12px;
  box-shadow:0 2px 10px rgba(15,24,42,.06);
}

#sidebar .card h4{
  margin:0 0 10px;
  font-size:12px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.08em;
  color:var(--app-muted) !important;
}

#sidebar #user-list{
  display:grid;
  gap:8px;
}

#sidebar .user-row{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 10px;
  border-radius:10px;
  background:color-mix(in srgb, var(--app-control), transparent 34%);
}

#sidebar .user-row__avatar{
  width:28px;
  height:28px;
  border-radius:999px;
  display:grid;
  place-items:center;
  font-size:12px;
  font-weight:700;
  color:#fff;
  background:linear-gradient(145deg, #4f87ff, #2d64da);
  flex:0 0 28px;
}

#sidebar .user-row__meta{ min-width:0; }

#sidebar .user-row__name{
  font-size:13px;
  font-weight:600;
  line-height:1.2;
  color:var(--app-text);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

#sidebar .user-row__role{
  margin-top:2px;
  font-size:11px;
  color:var(--app-muted);
}

#sidebar #chat-log{
  height:clamp(220px, 32vh, 360px);
  padding:10px;
  border-radius:12px;
  background:color-mix(in srgb, var(--app-surface-soft), var(--app-surface) 40%);
  display:flex;
  flex-direction:column;
  gap:8px;
  overflow:auto;
}

#sidebar .chat-msg{
  display:flex;
  flex-direction:column;
  gap:4px;
  max-width:88%;
  border-radius:12px;
  padding:8px 10px;
  line-height:1.3;
}

#sidebar .chat-msg__author{
  font-size:11px;
  font-weight:700;
  color:var(--app-muted);
}

#sidebar .chat-msg__text{
  font-size:13px;
  white-space:pre-wrap;
  word-break:break-word;
  color:var(--app-text);
}

#sidebar .chat-msg--other{
  align-self:flex-start;
  background:color-mix(in srgb, var(--app-control), transparent 24%);
}

#sidebar .chat-msg--me{
  align-self:flex-end;
  background:color-mix(in srgb, var(--app-primary), #fff 84%);
}

#sidebar .card .row{
  margin-top:10px;
  gap:8px;
}

#sidebar #chat-input{
  flex:1;
  min-height:40px;
  padding:10px 12px;
  border-radius:12px;
  background:var(--app-surface-soft) !important;
}

#sidebar #sendMsgBtn{
  min-width:78px;
  border-radius:12px;
  font-weight:700;
}

#sidebar #dropzone{
  border-radius:12px;
  padding:14px 12px;
  text-align:center;
  background:var(--app-surface-soft) !important;
}

#sidebar .attach-item{
  border-radius:10px;
  padding:8px 10px;
  background:var(--app-surface-soft);
}

body[data-theme="dark"] #sidebar .card{
  box-shadow:none;
}

body[data-theme="dark"] #sidebar .chat-msg--other{
  background:color-mix(in srgb, #1f2f4d, transparent 8%);
}

body[data-theme="dark"] #sidebar .chat-msg--me{
  background:color-mix(in srgb, var(--app-primary), #0b1220 62%);
}

/* Attachments actions: icon-only, perfectly aligned */
#sidebar .attach-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

#sidebar .attach-item .meta{
  min-width:0;
  flex:1;
}

#sidebar .attach-item .name{
  font-weight:600;
  line-height:1.25;
  word-break:break-word;
}

#sidebar .attach-item .size{
  margin-top:3px;
  font-size:12px;
  color:var(--app-muted);
}

#sidebar .attach-item .actions{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  gap:6px;
}

#sidebar .attach-act-btn{
  width:34px;
  height:34px;
  min-width:34px;
  min-height:34px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:10px;
  background:var(--app-control);
  color:var(--app-text);
  text-decoration:none;
  border:none;
  padding:0;
  cursor:pointer;
}

#sidebar .attach-act-btn .ico{
  width:16px;
  height:16px;
  display:block;
}

#sidebar .attach-act-btn:hover{
  background:var(--app-control-hover);
}

#sidebar .attach-act-btn--danger{
  color:#b93445;
  background:color-mix(in srgb, #f5c7cd, var(--app-surface) 55%);
}

body[data-theme="dark"] #sidebar .attach-act-btn--danger{
  color:#ffb2be;
  background:color-mix(in srgb, #70202b, var(--app-surface) 68%);
}

/* Host button: consistent with app control language */
#hostDashBtn.host-dashboard-btn{
  width:46px;
  height:46px;
  min-width:46px;
  min-height:46px;
  border-radius:12px;
  background:color-mix(in srgb, var(--app-primary), #fff 96%);
  color:var(--app-primary);
}

#hostDashBtn.host-dashboard-btn .ico{
  width:19px;
  height:19px;
}

#hostDashBtn.host-dashboard-btn:hover{
  background:color-mix(in srgb, var(--app-primary), #fff 90%);
}

#hostDashBtn.host-dashboard-btn.active{
  background:color-mix(in srgb, var(--app-primary), #fff 82%);
  color:#1b55d5;
  box-shadow:none;
}

body[data-theme="dark"] #hostDashBtn.host-dashboard-btn{
  background:var(--app-control);
  color:var(--app-text);
}

body[data-theme="dark"] #hostDashBtn.host-dashboard-btn:hover{
  background:var(--app-control-hover);
}

body[data-theme="dark"] #hostDashBtn.host-dashboard-btn.active{
  background:color-mix(in srgb, var(--app-primary), #0b1220 58%);
  color:#dcebff;
  box-shadow:none;
}

/* Accessibility helper */
.sr-only{
  position:absolute !important;
  width:1px !important;
  height:1px !important;
  padding:0 !important;
  margin:-1px !important;
  overflow:hidden !important;
  clip:rect(0,0,0,0) !important;
  white-space:nowrap !important;
  border:0 !important;
}

#roomSelect{
  width:100%;
  appearance:none;
  -webkit-appearance:none;
  border:1px solid var(--border);
  background:var(--panel);
  color:var(--text);
  border-radius:12px;
  padding:12px 42px 12px 14px;
  font:inherit;
  font-weight:600;
  line-height:1.2;
  outline:none;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px);
  background-size:6px 6px, 6px 6px;
  background-repeat:no-repeat;
}
#roomSelect:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 3px color-mix(in srgb, var(--accent), transparent 78%);
}

.room-cards{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:10px;
}
.room-card-btn{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:12px 14px;
  border:1px solid var(--border);
  border-radius:14px;
  background:var(--panel);
  color:var(--text);
  cursor:pointer;
  transition:border-color .15s, background .15s, transform .12s;
}
.room-card-btn:hover{
  background:color-mix(in srgb, var(--accent), var(--panel) 92%);
}
.room-card-btn.is-active{
  border-color:var(--accent);
  background:color-mix(in srgb, var(--accent), var(--panel) 86%);
  box-shadow:0 0 0 2px color-mix(in srgb, var(--accent), transparent 78%);
}
.room-card-name{
  font-weight:700;
  font-size:13px;
}
.room-card-count{
  min-width:30px;
  height:26px;
  border-radius:999px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:color-mix(in srgb, var(--accent), transparent 84%);
  color:var(--accent);
  font-weight:800;
  font-size:12px;
}
@media (max-width:640px){
  .room-cards{ grid-template-columns:1fr; }
}

/* =========================================================
   NUOVO PANNELLO PREJOIN — redesign 2026
   ========================================================= */

/* Overlay */
#prejoin {
  background:
    radial-gradient(ellipse 120% 80% at 18% -10%, rgba(224,176,120,.08) 0%, transparent 56%),
    radial-gradient(ellipse 90% 65% at 86% 110%, rgba(140,167,210,.08) 0%, transparent 52%),
    linear-gradient(145deg, rgba(8,13,24,.9) 0%, rgba(12,18,31,.92) 100%);
}

/* Panel: split-screen, no padding */
#prejoin .modal__panel {
  width: min(1040px, 97vw);
  max-width: none;
  height: min(680px, 94dvh);
  max-height: none;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: row;
  border-radius: 26px;
  border: 1px solid rgba(227,233,244,.08);
  box-shadow: 0 40px 100px rgba(0,0,0,.58), 0 0 0 1px rgba(255,255,255,.03);
  background: none;
}

/* ---- LEFT col: camera preview ---- */
.pj-scroll-body {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.pj-left {
  flex: 0 0 52%;
  position: relative;
  background:
    radial-gradient(circle at 20% 15%, rgba(223,179,124,.1), transparent 30%),
    linear-gradient(180deg, #111a2a 0%, #090f18 100%);
  overflow: hidden;
}

.pj-left video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transform: scaleX(-1);
  display: block;
}

.pj-preview-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 4;
  background: rgba(14,18,27,.56);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: rgba(255,255,255,.78);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.1);
}

/* Device controls floating at the bottom */
.pj-preview-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 4;
  padding: 48px 16px 16px;
  background: linear-gradient(0deg, rgba(0,0,0,.82) 0%, transparent 100%);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.pj-dev-group {
  display: flex;
  align-items: stretch;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.11);
  background: rgba(14,18,27,.56);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.pj-dev-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-right: 1px solid rgba(255,255,255,.08);
  color: #fff;
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
}
.pj-dev-btn:hover { background: rgba(255,255,255,.09); }
.pj-dev-btn .ico { width: 18px; height: 18px; }

.pj-dev-select-wrap {
  position: relative;
  width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(255,255,255,.72);
  transition: background .15s;
}
.pj-dev-select-wrap:hover { background: rgba(255,255,255,.07); }

.pj-dev-chevron {
  width: 10px;
  height: 10px;
  pointer-events: none;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.pj-dev-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
}

/* ---- RIGHT col: form ---- */
.pj-right {
  flex: 1;
  min-width: 0;
  padding: 32px 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: visible;
  background:
    linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.015)),
    linear-gradient(155deg, #10192a 0%, #0d1624 58%, #0b121e 100%);
}

/* Brand header */
.pj-brand {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 28px;
  flex-shrink: 0;
}
.pj-brand-copy{
  min-width:0;
}
.pj-brand-mobile{
  display:none;
  margin:0;
}

.pj-brand-icon {
  width: 86px;
  height: 86px;
  border-radius: 0;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: visible;
  box-shadow: none;
}
.pj-brand-icon svg { width: 22px; height: 22px; color: #fff; }
.pj-brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

body[data-theme="dark"] .pj-brand-logo {
  filter: brightness(0) invert(1) saturate(0.92) contrast(1.04);
}

.pj-brand-name {
  font-size: 1.34rem;
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--txt, #eaf2ff);
  line-height: 1.1;
}
.pj-brand-sub {
  font-size: 12px;
  color: rgba(222,231,245,.7);
  margin-top: 4px;
  letter-spacing: .01em;
}

/* Field wrappers */
.pj-field {
  margin-bottom: 18px;
  flex-shrink: 0;
}
.pj-field:last-of-type { margin-bottom: 0; }

.pj-field-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(210,221,239,.62);
  margin-bottom: 8px;
}

/* Name input */
.pj-input {
  width: 100%;
  padding: 13px 15px;
  border-radius: 13px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.05);
  color: var(--txt, #eaf2ff);
  font-size: 15px;
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s, transform .15s;
  display: block;
  margin-bottom: 0;
}
.pj-input::placeholder { color: rgba(255,255,255,.32); }
.pj-input:focus {
  border-color: rgba(218,175,120,.42);
  box-shadow: 0 0 0 3px rgba(218,175,120,.08);
  background: rgba(255,255,255,.07);
  transform: translateY(-1px);
}

/* Entry mode switch — override base styles within #prejoin */
#prejoin .entry-mode-switch {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 8px;
  background: none;
  border: none;
  padding: 0;
  border-radius: 0;
}
#prejoin .entry-mode-btn {
  padding: 11px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.045);
  color: rgba(230,236,246,.72);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: border-color .15s, background .15s, color .15s, transform .12s, box-shadow .15s;
  text-decoration: none;
  cursor: pointer;
}
#prejoin .entry-mode-btn .ico { width: 17px; height: 17px; }
#prejoin .entry-mode-btn--audio {
  width: 46px;
  min-width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 999px;
  gap: 0;
  justify-self: end;
  border-color: rgba(218,175,120,.22);
  background: linear-gradient(135deg, rgba(218,175,120,.08), rgba(255,255,255,.05));
  color: #f0dcc0;
  box-shadow: 0 0 0 1px rgba(218,175,120,.08);
}
#prejoin .entry-mode-btn--audio .ico {
  width: 18px;
  height: 18px;
}
#prejoin .entry-mode-btn--audio:hover {
  border-color: rgba(218,175,120,.34);
  background: linear-gradient(135deg, rgba(218,175,120,.14), rgba(255,255,255,.07));
  color: #fff4e4;
}
#prejoin .entry-mode-btn:hover {
  border-color: rgba(218,175,120,.24);
  background: rgba(218,175,120,.05);
  color: #fff;
  transform: translateY(-1px);
}
#prejoin .entry-mode-btn.is-active {
  border-color: rgba(218,175,120,.26);
  background: linear-gradient(135deg, rgba(218,175,120,.08), rgba(255,255,255,.05));
  color: #fff;
  box-shadow: 0 0 0 1px rgba(218,175,120,.08), 0 8px 18px rgba(0,0,0,.1);
}

/* Room cards — override base within #prejoin */
#prejoin .room-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
#prejoin .room-card-btn {
  min-width: 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.03));
  color: rgba(230,236,246,.76);
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  transition: border-color .15s, background .15s, transform .12s, box-shadow .15s;
}
#prejoin .room-card-btn:hover {
  border-color: rgba(218,175,120,.24);
  background: linear-gradient(180deg, rgba(218,175,120,.05), rgba(255,255,255,.05));
  color: #fff;
  transform: translateY(-1px);
}
#prejoin .room-card-btn.is-active {
  border-color: rgba(218,175,120,.75);
  background: linear-gradient(135deg, rgba(218,175,120,.18), rgba(255,255,255,.08));
  color: #fff;
  box-shadow: 0 0 0 2.5px rgba(218,175,120,.38), 0 8px 20px rgba(0,0,0,.1);
}
#prejoin .room-card-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 1px;
}
#prejoin .room-card-name { font-weight: 700; }
#prejoin .room-card-lesson {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#prejoin .room-card-lesson-sub {
  font-size: 9px;
  line-height: 1.2;
  opacity: .72;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#prejoin .room-card-count {
  background: rgba(255,255,255,.12);
  color: #ead5b5;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  min-width: 38px;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
}
#prejoin .room-card-count-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  opacity: .82;
}
#prejoin .room-card-count-value {
  line-height: 1;
}

/* Join button + admin */
.pj-actions {
  margin-top: 24px;
  padding-top: 18px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}

/* #prejoin .pj-join: specificity 110 beats old #joinBtn rules (specificity 100) */
#prejoin .pj-join {
  flex: 1;
  height: 52px;
  background: linear-gradient(135deg, #cfa777 0%, #b98b5d 100%);
  border: none;
  border-radius: 14px;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .01em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform .2s ease, box-shadow .2s ease;
  box-shadow: 0 14px 28px rgba(135,88,43,.2);
  width: auto;
  min-width: 0;
  padding: 0 20px;
}
#prejoin .pj-join:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(135,88,43,.24);
}
#prejoin .pj-join:active { transform: translateY(0); }

.pj-admin-btn {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  color: rgba(255,255,255,.45);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, color .15s, border-color .15s;
}
.pj-admin-btn:hover {
  background: rgba(255,255,255,.09);
  color: rgba(255,255,255,.82);
  border-color: rgba(218,175,120,.26);
}

/* ---- Light theme overrides ---- */
body[data-theme="light"] #prejoin {
  background:
    radial-gradient(ellipse 115% 80% at 14% -10%, rgba(219,177,126,.1) 0%, transparent 58%),
    radial-gradient(ellipse 85% 70% at 100% 0%, rgba(190,205,230,.18) 0%, transparent 48%),
    linear-gradient(180deg, #f7f3ec 0%, #eef3fb 100%);
}
body[data-theme="light"] #prejoin .modal__panel {
  border-color: rgba(24,41,70,.08);
  box-shadow: 0 28px 64px rgba(29,49,86,.14);
}
body[data-theme="light"] .pj-left {
  background:
    radial-gradient(circle at 18% 15%, rgba(221,181,130,.14), transparent 32%),
    linear-gradient(180deg, #d9e3f2 0%, #cbd7e8 100%);
}
body[data-theme="light"] .pj-right {
  background:
    linear-gradient(180deg, rgba(255,255,255,.82), rgba(255,255,255,.72)),
    linear-gradient(155deg, #fbf8f2 0%, #f7f2ea 30%, #f2f5fb 100%);
}
body[data-theme="light"] .pj-brand-name { color: #0f1f3d; }
body[data-theme="light"] .pj-brand-sub { color: #6d7d98; }
body[data-theme="light"] .pj-brand-icon {
  background: transparent;
  border: none;
  box-shadow: none;
}
body[data-theme="light"] .pj-field-label { color: #70809b; }
body[data-theme="light"] .pj-input {
  background: rgba(255,255,255,.88);
  border-color: rgba(24,41,70,.1);
  color: #0f1f3d;
}
body[data-theme="light"] .pj-input::placeholder { color: #96a3b8; }
body[data-theme="light"] .pj-input:focus {
  border-color: rgba(200,152,98,.62);
  box-shadow: 0 0 0 3px rgba(200,152,98,.1);
  background: #fff;
}
body[data-theme="light"] #prejoin .entry-mode-btn {
  border-color: rgba(24,41,70,.08);
  background: rgba(255,255,255,.84);
  color: #50627e;
}
body[data-theme="light"] #prejoin .entry-mode-btn:hover {
  border-color: rgba(200,152,98,.26);
  background: rgba(200,152,98,.05);
  color: #8d5f30;
}
body[data-theme="light"] #prejoin .entry-mode-btn.is-active {
  border-color: rgba(200,152,98,.3);
  background: linear-gradient(135deg, rgba(215,173,116,.1), rgba(255,255,255,.55));
  color: #8d5f30;
  box-shadow: 0 0 0 1px rgba(200,152,98,.1);
}
body[data-theme="light"] #prejoin .entry-mode-btn--audio {
  border-color: rgba(200,152,98,.24);
  background: linear-gradient(135deg, rgba(215,173,116,.12), rgba(255,255,255,.82));
  color: #8d5f30;
  box-shadow: 0 0 0 1px rgba(200,152,98,.08);
}
body[data-theme="light"] #prejoin .entry-mode-btn--audio:hover {
  border-color: rgba(200,152,98,.34);
  background: linear-gradient(135deg, rgba(215,173,116,.18), rgba(255,255,255,.94));
  color: #744822;
}
body[data-theme="light"] #prejoin .room-card-btn {
  border-color: rgba(24,41,70,.08);
  background: linear-gradient(180deg, rgba(255,255,255,.94), rgba(250,252,255,.88));
  color: #455877;
}
body[data-theme="light"] #prejoin .room-card-btn:hover {
  border-color: rgba(200,152,98,.26);
  background: linear-gradient(180deg, rgba(255,248,240,.98), rgba(252,245,235,.9));
  color: #8d5f30;
}
body[data-theme="light"] #prejoin .room-card-btn.is-active {
  border-color: rgba(200,152,98,.72);
  background: linear-gradient(135deg, rgba(215,173,116,.22), rgba(255,248,240,.95));
  color: #7a4e1c;
  box-shadow: 0 0 0 2.5px rgba(200,152,98,.32), 0 8px 18px rgba(146,98,50,.09);
}
body[data-theme="light"] #prejoin .room-card-count {
  background: rgba(215,173,116,.12);
  color: #8d5f30;
}
body[data-theme="light"] .pj-join {
  box-shadow: 0 12px 24px rgba(168,117,67,.16);
}
body[data-theme="light"] .pj-admin-btn {
  border-color: rgba(24,41,70,.08);
  background: rgba(255,255,255,.82);
  color: #8fa0b8;
}

/* ---- Responsive ---- */
@media (max-width: 700px) {
  #prejoin {
    padding: 8px !important;
    overflow-x: hidden;
  }
  #prejoin .modal__panel {
    flex-direction: column;
    width: min(560px, 100%);
    max-width: 560px;
    height: min(820px, 96dvh);
    border-radius: 20px;
    justify-content:flex-start;
    align-items:center;
    margin:0 auto;
  }
  .pj-scroll-body {
    width: 100%;
    flex: 1;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    align-items: center;
    padding-bottom: 12px;
    -webkit-overflow-scrolling: touch;
  }
  #prejoin .modal__panel,
  #prejoin .modal__panel *,
  #prejoin .pj-left,
  #prejoin .pj-right,
  #prejoin .pj-scroll-body,
  #prejoin .pj-brand-mobile {
    box-sizing: border-box;
  }
  .pj-brand-mobile{
    display:flex;
    align-items:center;
    justify-content:center;
    gap:12px;
    padding:18px 18px 10px;
    text-align:center;
    width:calc(100% - 32px);
    max-width:460px;
    margin:0 auto;
  }
  .pj-left {
    flex: 0 0 auto;
    min-height: 220px;
    height:min(33dvh, 280px);
    width:calc(100% - 32px);
    max-width:460px;
    margin:0 auto;
    border-radius:18px;
  }
  .pj-right {
    flex: 0 0 auto;
    width:100%;
    min-height: 0;
    padding: 18px 16px 16px;
    overflow: visible;
    align-items:center;
  }
  .pj-right > *{
    width:100%;
    max-width:460px;
    margin-left:auto;
    margin-right:auto;
  }
  .pj-right .pj-brand {
    display:none;
  }
  .pj-brand-icon {
    width: 72px;
    height: 72px;
  }
  .pj-field { margin-bottom: 12px; }
  .pj-field-label { margin-bottom: 6px; }
  .pj-input {
    font-size: 16px;
    padding: 12px 14px;
  }
  .pj-preview-controls {
    padding: 42px 12px 12px;
    gap: 8px;
    justify-content:flex-start;
  }
  .pj-dev-group {
    min-width: 0;
  }
  .pj-join { height: 48px; font-size: 15px; }
  #prejoin .room-cards {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  #prejoin .room-card-btn {
    padding: 10px 11px;
  }
  #prejoin .room-card-lesson,
  #prejoin .room-card-lesson-sub {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
  .pj-actions {
    margin-top: 18px;
    padding-top: 14px;
    width: 100%;
    max-width: 460px;
  }
}

@media (max-width: 420px) {
  #prejoin {
    padding: 6px !important;
    overflow-x: hidden;
  }
  #prejoin .modal__panel {
    width: min(560px, 100%);
    max-width: 560px;
    height: min(100dvh - 10px, 860px);
    border-radius: 18px;
    align-items:center;
    margin:0 auto;
  }
  .pj-left {
    min-height: 190px;
  }
  .pj-scroll-body {
    padding-bottom: 10px;
  }
  .pj-right { padding: 15px 13px 14px; }
  .pj-brand-mobile {
    padding:16px 14px 8px;
    gap:10px;
    width:calc(100% - 26px);
  }
  .pj-left {
    width:calc(100% - 26px);
  }
  .pj-brand-icon {
    width: 60px;
    height: 60px;
  }
  .pj-brand-name {
    font-size: 1.16rem;
  }
  .pj-brand-sub {
    font-size: 11px;
  }
  .pj-preview-controls {
    padding: 34px 10px 10px;
  }
  .pj-dev-btn {
    width: 42px;
    height: 42px;
  }
  .pj-dev-select-wrap {
    width: 30px;
  }
  #prejoin .entry-mode-switch {
    grid-template-columns: minmax(0, 1fr) 42px;
  }
  #prejoin .entry-mode-btn--audio,
  .pj-admin-btn {
    width: 42px;
    min-width: 42px;
    height: 42px;
  }
  .pj-actions {
    gap: 8px;
  }
  #prejoin .pj-join {
    padding: 0 14px;
    font-size: 14px;
  }
}

/* ======= Lesson Info Modal ======= */
/* ======= Lesson Info Modal ======= */
.lesson-info-panel {
  max-width: min(460px, 96vw);
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #fff;
}
body[data-theme="dark"] .lesson-info-panel {
  background: var(--panel);
}

/* Header */
.lesson-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #e8e8e8;
}
body[data-theme="dark"] .lesson-info-header { border-bottom-color: var(--border); }
.lesson-info-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Read-only view */
.lesson-info-empty {
  color: #999;
  font-size: 14px;
  padding: 12px 0 4px;
  text-align: center;
}
.lesson-info-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lesson-info-tag {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 999px;
  align-self: flex-start;
  letter-spacing: .03em;
}
.lesson-info-sub {
  color: #888;
  font-size: 13px;
  font-style: italic;
}
.lesson-info-text {
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  margin: 0;
}

/* Edit fields */
.lesson-info-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lesson-info-label {
  font-size: 11px;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.lesson-info-select,
.lesson-info-input,
.lesson-info-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid #ddd;
  background: #f7f7f7;
  color: #222;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
body[data-theme="dark"] .lesson-info-select,
body[data-theme="dark"] .lesson-info-input,
body[data-theme="dark"] .lesson-info-textarea {
  border-color: var(--border);
  background: var(--panel-2);
  color: var(--text);
}
.lesson-info-select:focus,
.lesson-info-input:focus,
.lesson-info-textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}
.lesson-info-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid #e8e8e8;
}
body[data-theme="dark"] .lesson-info-actions { border-top-color: var(--border); }

/* Gestione argomenti */
.lesson-topics-manage {
  border-radius: 10px;
  border: 1px solid #e0e0e0;
  overflow: hidden;
}
body[data-theme="dark"] .lesson-topics-manage { border-color: var(--border); }
.lesson-topics-summary {
  cursor: pointer;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: .06em;
  list-style: none;
  user-select: none;
  background: #f7f7f7;
  display: flex;
  align-items: center;
  gap: 6px;
}
body[data-theme="dark"] .lesson-topics-summary { background: var(--panel-2); color: var(--muted); }
.lesson-topics-summary::-webkit-details-marker { display: none; }
.lesson-topics-summary::before {
  content: '▸';
  display: inline-block;
  transition: transform .2s;
  font-size: 9px;
}
.lesson-topics-manage[open] .lesson-topics-summary::before { transform: rotate(90deg); }
.lesson-topics-manage > .lesson-topics-add-row { padding: 10px 10px 0; }
.lesson-topics-manage > .lesson-topics-list { padding: 8px 10px 10px; }
.lesson-topics-add-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.lesson-topics-add-row .lesson-info-input { flex: 1; }
.lesson-topics-add-row .ghost {
  flex-shrink: 0;
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 10px;
  white-space: nowrap;
}
.lesson-topics-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.lesson-topic-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #efefef;
  border: 1px solid #ddd;
  border-radius: 999px;
  padding: 3px 6px 3px 10px;
  font-size: 13px;
  color: #333;
}
body[data-theme="dark"] .lesson-topic-item {
  background: var(--panel-2);
  border-color: var(--border);
  color: var(--text);
}
.lesson-topic-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  background: transparent;
  color: #aaa;
  border-radius: 999px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  transition: background .15s, color .15s;
}
.lesson-topic-remove:hover { background: var(--danger); color: #fff; }

/* ── Specchio videocamera locale (escluso screen share) ── */
.tile[data-local-media="1"]:not([id*="screen-"]) video { transform: scaleX(-1); }
#previewVideo { transform: scaleX(-1); }
