/* Видеоурок — дополняет app.css и chat.css */

/* ---------- вход (проверка камеры) ---------- */
.lobby { max-width: 980px; margin: 0 auto; }
.lobby-card {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 28px; align-items: center; margin-top: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); padding: 24px;
}
.preview { position: relative; aspect-ratio: 16 / 10; background: #10131c; border-radius: 18px; overflow: hidden; }
.preview-video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.preview-off { position: absolute; inset: 0; display: none; place-items: center; color: #aab; font-weight: 600; }
.preview.cam-off .preview-video { display: none; }
.preview.cam-off .preview-off { display: grid; }
.lobby-toggles { display: flex; align-items: center; gap: 10px; justify-content: center; margin-top: 12px; }
.round-btn {
  width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--line); background: var(--card);
  font-size: 1.35rem; cursor: pointer; box-shadow: var(--shadow);
}
.round-btn.off { background: color-mix(in srgb, var(--danger) 15%, var(--card)); }
.mic-meter { width: 90px; height: 8px; border-radius: 99px; background: var(--paper-2); overflow: hidden; }
.mic-meter span { display: block; height: 100%; width: 0; background: var(--m5); transition: width .08s; }
.lobby-right h1 { margin-bottom: 4px; }
.lobby-status { font-weight: 600; margin: 18px 0 12px; }
.lobby-tips { color: var(--muted); font-size: .9rem; padding-left: 18px; margin: 18px 0 0; display: grid; gap: 4px; }

/* ---------- комната ---------- */
body[data-page=live] { overflow: hidden; background: #0f121a; }
body[data-page=live] .topbar, body[data-page=live] .tabbar { display: none !important; }
body[data-page=live] .app { max-width: none; padding: 0; }
body[data-page=live] .app > .page, body[data-page=live] .app > .loading { background: var(--paper); min-height: 100vh; padding: 28px 16px; }
body[data-page=live] .app > .lobby { background: var(--paper); min-height: 100vh; max-width: none; padding: 24px max(16px, calc((100vw - 980px) / 2)); overflow-y: auto; height: 100vh; }

.live { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; color: #e9ecf5; background: #0f121a; }
.live-top { display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.live-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-title .muted, .live-timer { color: #9aa3bd; }
.live-timer { font-variant-numeric: tabular-nums; }
.live-badges { display: flex; gap: 8px; align-items: center; }
.rec-badge { color: #ff6b6b; font-weight: 700; font-size: .85rem; animation: pulse 1.6s infinite; }
.conn-badge { color: #ffcc66; font-weight: 600; font-size: .85rem; }
.live-body { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 0; }
.live.with-panel .live-body { grid-template-columns: minmax(0, 1fr) 360px; }
.live-main { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 0; padding: 10px; gap: 10px; }

.stage { min-height: 0; display: grid; gap: 8px; }
.stage.focus { place-items: center; }
.stage.focus > * { width: 100%; height: 100%; max-height: 100%; min-height: 0; }
.stage.focus { grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); }
.stage.grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); grid-auto-rows: minmax(0, 1fr); align-content: stretch; }
.stage.grid.n1 { grid-template-columns: minmax(0, 900px); justify-content: center; }
.stage.grid.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stage.grid.n3, .stage.grid.n4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stage-empty { display: grid; place-items: center; text-align: center; color: #9aa3bd; padding: 20px; border: 2px dashed rgba(255, 255, 255, .12); border-radius: 18px; }
.strip { display: flex; gap: 8px; overflow-x: auto; min-height: 0; }
.strip .tile { width: 168px; flex: none; aspect-ratio: 16 / 10; }
.strip:empty { display: none; }

.tile {
  position: relative; background: #1b2030; border-radius: 14px; overflow: hidden; min-height: 0;
  border: 2px solid transparent; transition: border-color .15s;
}
.stage.focus .tile { aspect-ratio: auto; }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile[data-id] video { background: #1b2030; }
.tile.no-video video { display: none; }
.t-avatar {
  position: absolute; inset: 0; margin: auto; width: 34%; max-width: 110px; aspect-ratio: 1; border-radius: 50%;
  display: none; place-items: center; background: var(--sky); color: #fff; font: 700 clamp(1rem, 3vw, 2rem) var(--sans);
}
.tile.teacher .t-avatar { background: var(--gold); }
.tile.no-video .t-avatar { display: grid; }
.t-label {
  position: absolute; left: 6px; bottom: 6px; right: 6px; display: flex; gap: 6px; align-items: center;
  font-size: .82rem; font-weight: 600;
}
.t-name { background: rgba(10, 12, 20, .62); padding: 2px 8px; border-radius: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-mic, .t-hand { background: rgba(10, 12, 20, .62); border-radius: 8px; padding: 1px 5px; }
.t-mic:empty { display: none; }
.tile.speaking { border-color: var(--m5); }
.tile.hand { border-color: var(--gold); }
.tile.chalk { box-shadow: 0 0 0 3px var(--sky) inset; }
.tile.teacher .t-name::after { content: " · учитель"; color: var(--gold); }
.tile.clickable { cursor: pointer; }
.tile.clickable:hover { border-color: rgba(255, 255, 255, .35); }
/* себя видим зеркально — привычнее */
.tile[data-id].self video { transform: scaleX(-1); }

.screen-view { position: relative; background: #000; border-radius: 14px; overflow: hidden; display: grid; place-items: center; }
.screen-view video { width: 100%; height: 100%; object-fit: contain; }
.screen-label { position: absolute; left: 8px; top: 8px; background: rgba(10, 12, 20, .62); padding: 3px 9px; border-radius: 8px; font-size: .82rem; }

/* ---------- доска ---------- */
.board { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 8px; min-height: 0; }
/* холст вписывается в свободное место с сохранением пропорций 16:10 */
.board-paper { min-height: 0; position: relative; }
.board-canvas {
  position: absolute; inset: 0; margin: auto; width: auto; height: auto; max-width: 100%; max-height: 100%;
  border-radius: 12px; background: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); touch-action: none; display: block;
}
.board.can-draw .board-canvas { cursor: crosshair; }
.board-tools { display: flex; gap: 6px; align-items: center; justify-content: center; flex-wrap: wrap; }
.board-tools .color { width: 30px; height: 30px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.board-tools .color.on { border-color: #fff; box-shadow: 0 0 0 2px var(--gold); }
.board-tools .tool {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .15);
  background: #1b2030; color: #fff; cursor: pointer; font-size: 1.05rem;
}
.board-tools .tool.on { background: var(--navy); border-color: var(--gold); }
.board-tools select.compact { min-width: 110px; min-height: 36px; padding: 4px 10px; background: #1b2030; color: #fff; border-color: rgba(255, 255, 255, .15); }
.board-note { color: #9aa3bd; font-size: .88rem; }

/* ---------- кнопки внизу ---------- */
.live-bar {
  display: flex; justify-content: center; gap: 6px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, .08); overflow-x: auto;
}
.bar-btn {
  display: grid; justify-items: center; gap: 2px; min-width: 74px; padding: 7px 8px; border-radius: 12px;
  border: 0; background: #1b2030; color: #e9ecf5; cursor: pointer; font: 600 .74rem var(--sans); flex: none;
}
.bar-btn:hover { background: #262c40; }
.bar-btn:disabled { opacity: .45; cursor: not-allowed; }
.bar-icon { font-size: 1.3rem; line-height: 1.2; }
.bar-btn.on { background: #2c3a7a; box-shadow: inset 0 0 0 2px var(--gold); }
.bar-btn.off { background: #3a2028; }
.bar-btn.danger { background: #b3261e; color: #fff; }
.bar-btn.danger:hover { background: #8f1e18; }

/* ---------- боковая панель ---------- */
.live-panel { background: var(--card); color: var(--ink); display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line); }
.live-panel .conv { flex: 1; }
.live-panel .conv-head { display: none; }
.panel-scroll { overflow-y: auto; padding: 4px 14px 14px; }
.people-live { list-style: none; margin: 0; padding: 0; }
.person-row { display: flex; align-items: center; gap: 8px; padding: 8px 2px; border-bottom: 1px solid var(--line); }
.pr-name { flex: 1; min-width: 0; font-weight: 600; }
.pr-icons { font-size: .9rem; }
.m-menu-title { font-weight: 700; padding: 6px 12px 4px; font-size: .9rem; color: var(--muted); }
.absent-list { display: grid; gap: 2px; margin-bottom: 12px; }

/* ---------- кнопки входа на страницах ---------- */
.live-card { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; border-left: 5px solid var(--m5); }
.live-card .grow { flex: 1; min-width: 200px; }
.live-card.on { background: color-mix(in srgb, var(--m5) 10%, var(--card)); }
.live-pill { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; color: #fff; background: var(--m5); padding: 2px 9px; border-radius: 999px; }
.live-toast { border-left-color: var(--m5) !important; }

@media (max-width: 860px) {
  .lobby-card { grid-template-columns: 1fr; padding: 16px; }
  .live.with-panel .live-body { grid-template-columns: 1fr; }
  .live.with-panel .live-panel { position: fixed; inset: 0 0 64px 0; z-index: 30; }
  .live-main { padding: 6px; gap: 6px; }
  .stage.grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; grid-auto-rows: minmax(110px, 1fr); overflow-y: auto; }
  .strip .tile { width: 112px; }
  .bar-btn { min-width: 60px; padding: 6px 4px; }
  .bar-label { font-size: .66rem; }
  .live-bar { justify-content: flex-start; }
}
.l-live { grid-column: 3 / -1; }
.visit { font-weight: 400; font-size: .82rem; color: var(--m5); margin-left: 4px; }
