.teaching-header {
  display: flex;
  gap: 1.2rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem clamp(1rem, 4vw, 4rem);
  border-bottom: 1px solid var(--line, #ffffff25);
}
.teaching-header nav,
.room-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.7rem;
}
.teaching-header h1 {
  font-size: 1.4rem;
}
.teaching-page {
  max-width: 1250px;
  margin: auto;
  padding: 1.5rem;
}
.teaching-page > p {
  max-width: 800px;
}
.teaching-page input,
.teaching-page select {
  max-width: 100%;
  padding: 0.65rem;
  border: 1px solid var(--line, #ffffff30);
  border-radius: 8px;
  background: var(--panel, #171025);
  color: inherit;
}
.teaching-page label {
  display: block;
}
.teaching-page .panel {
  margin-bottom: 1rem;
}
.teaching-page form {
  display: grid;
  gap: 1rem;
  max-width: 650px;
}
.teaching-page .room-actions {
  margin-bottom: 1rem;
}
.room-actions input[type="range"] {
  width: 100px;
}
.room-actions input[type="color"] {
  padding: 3px;
  width: 45px;
  height: 40px;
}
.room-actions p {
  font-size: 0.82rem;
  margin: 0;
}
.teaching-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 285px;
  gap: 1rem;
}
.teaching-layout:has(#teacher-panel[hidden]) {
  grid-template-columns: minmax(0, 1fr);
}
.teaching-stage {
  position: relative;
  aspect-ratio: 16/9;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  border: 1px solid #999;
}
.teaching-stage.overlay {
  background: #13111b;
}
.clean-stage { overflow: hidden; }
.clean-stage .teaching-stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 5000;
  background: #000;
  border: 0;
  border-radius: 0;
}
.clean-stage .teaching-stage #featured-video,
.clean-stage .teaching-stage #teaching-board {
  width: min(100vw, 177.777778vh);
  height: min(100vh, 56.25vw);
  inset: auto;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.clean-stage .teaching-stage:not(.overlay) #teaching-board {
  background: #fff;
}
.teaching-stage canvas {
  position: absolute;
  width: 100%;
  height: 100%;
  inset: 0;
  touch-action: none;
}
.teaching-stage canvas.readonly {
  pointer-events: none;
}
.teaching-stage #featured-video {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
}
.teaching-stage.overlay #featured-video {
  display: flex;
}
.teaching-stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.teaching-stage video.stage-face {
  position: absolute;
  right: 2%;
  bottom: 3%;
  width: 25%;
  height: auto;
  aspect-ratio: 16/9;
  border: 2px solid #bf7bff;
  border-radius: 12px;
  box-shadow: 0 6px 24px #0009;
  background: #0c0815;
}
.role-notice { padding: .8rem 1rem; border: 1px solid #b985ff60; border-radius: 12px; background: #9264cf14; }
.teaching-viewer .navigation-toggle,
.teaching-viewer .navigation-go-live,
.teaching-viewer .cockpit-dock { display: none !important; }
.room-page #background-tools { max-width: 720px; }
.room-page #background-tools input[type="checkbox"] { width: auto; }
.room-page #background-tools .check { display: flex; gap: .6rem; align-items: start; }
.room-page #camera-look-status { font-size: .9rem; }
.teaching-stage #stage-empty {
  color: #ddd;
}
.teaching-stage-section {
  min-width: 0;
}
.video-tiles {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
}
.video-tile {
  width: 180px;
  position: relative;
  border: 1px solid #9c6dd1;
  border-radius: 10px;
  overflow: hidden;
  background: #080711;
}
.video-tile video {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: contain;
}
.video-tile p {
  font-size: 0.8rem;
  margin: 0.4rem;
  color: #fff;
}
.video-tile button {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.video-tile button:focus-visible {
  opacity: 1;
}
.teaching-page aside input {
  width: 100%;
  margin: 0.5rem 0;
}
.person {
  padding: 0.7rem 0;
  border-top: 1px solid #ffffff25;
}
.person .btn {
  margin: 0.3rem 0.3rem 0 0;
}
#board-connection {
  font-size: 0.85rem;
}
#board-transcript {
  white-space: pre-wrap;
}
#room-status {
  min-height: 1.5em;
}
#teacher-status {
  overflow-wrap: anywhere;
}
.room-page {
  max-width: 1600px;
}
.room-page [hidden] {
  display: none !important;
}
#rooms-status {
  color: #ff9fcc;
}
body[data-theme="light"] .teaching-stage {
  border-color: #c4bfd2;
}
@media (max-width: 850px) {
  .teaching-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .teaching-header {
    flex-wrap: wrap;
  }
  .teaching-page {
    padding: 1rem;
  }
  .teaching-header h1 {
    font-size: 1.15rem;
  }
  .teaching-page .btn {
    min-height: 42px;
  }
  .room-actions {
    gap: 0.45rem;
  }
  .room-actions label {
    font-size: 0.8rem;
  }
  .video-tile {
    width: 130px;
  }
}
.teaching-page .room-actions select {
  width: auto;
  max-width: 230px;
}
.teaching-page .room-actions input:not([type="color"]):not([type="range"]) {
  width: auto;
  max-width: 320px;
}
.teaching-page .room-actions input[type="file"] {
  width: 260px;
}
.teaching-page .room-actions label {
  margin: 0;
}
body > .navigation-skip {
  position: absolute;
  left: -10000px;
  top: 0;
}
body > .navigation-skip:focus {
  left: 1rem;
  z-index: 50;
}
.background-settings {
  margin: 0 0 1rem;
}
.background-settings summary {
  cursor: pointer;
  padding: 0.5rem 0;
}
.background-settings .room-actions {
  padding-top: 1rem;
}
#room-confirm {
  max-width: 440px;
  background: var(--panel, #171025);
  color: var(--text, #fff);
  border: 1px solid #b961ed;
  border-radius: 16px;
  padding: 1.5rem;
}
#room-confirm::backdrop {
  background: #000a;
}

#exit-clean-stage { position: absolute; z-index: 2; right: 1rem; top: 1rem; opacity: 0; }
#exit-clean-stage:hover, #exit-clean-stage:focus-visible { opacity: 1; }
.clean-stage .teaching-header,
.clean-stage #room-status,
.clean-stage #teacher-panel,
.clean-stage #room-workspace > :not(.teaching-layout),
.clean-stage .teaching-stage-section > :not(#teaching-stage):not(#room-audio) { display: none; }
.room-actions button[role="switch"][aria-checked="true"] {border-color:#8cfc79;background:#8cfc7925;box-shadow:inset 0 1px #ffffff55;}
#host-tool-switches label {display:flex;align-items:center;gap:10px;border:1px solid #ffffff30;border-radius:12px;padding:12px;}
#host-tool-switches input {accent-color:#8cfc79;width:22px;height:22px;}
.teaching-stage.portrait-stage {aspect-ratio:9/16;max-width:500px;margin:auto;}
.clean-stage .teaching-stage.portrait-stage {max-width:none;}
.clean-stage .portrait-stage #featured-video,.clean-stage .portrait-stage #teaching-board {width:min(100vw,56.25vh);height:min(100vh,177.777778vw);}
/* A host remains visible when teaching on a full whiteboard. */
.teaching-stage:not(.overlay) #featured-video {display:flex;}
.teaching-stage:not(.overlay) .stage-screen-track {display:none;}
.teaching-stage:not(.overlay) .stage-camera-track {position:absolute;right:2%;bottom:3%;width:25%;height:auto;aspect-ratio:16/9;border:2px solid #bf7bff;border-radius:12px;}
.clean-stage .teaching-stage:not(.overlay) {background:#fff;}
.clean-stage .teaching-stage:not(.overlay) #teaching-board {background:transparent;}
