/* r8: one shell, equal columns. Shared cabinet surface and lesson board recipes. */
.tl-lesson-room {
  --tl-room-space: 16px;
  --tl-room-radius: 16px;
  --tl-room-heading-size: 19px;
  --tl-room-column-min: 300px;
  --tl-room-floor: 106px;
  --tl-room-top: 104px;
  --tl-room-dock-block: 64px;
  --tl-room-divider: light-dark(#ddd, #262a36);
  --lc-panel: light-dark(#fff, #181b24);
  --lc-surface: light-dark(#f5f5f5, #1f2128);
  --lc-quote: light-dark(#fbeef9, #302232);
  --word-audio-size: 24px;
  --word-audio-glyph: 10px;
  --lc-text: light-dark(#1a1a1a,#e6e8ee);
  --lc-font-en: 'SF Mono',Menlo,monospace;
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  grid-template-rows: auto minmax(var(--tl-room-column-min),1fr);
  block-size: max(
    calc(100dvh - var(--tl-room-top) - var(--tl-room-floor)),
    calc(var(--tl-room-dock-block) + var(--tl-room-space) + var(--tl-room-column-min))
  );
  gap: var(--tl-room-space,16px);
  min-inline-size: 0;
}
.tl-lesson-room[hidden], .tl-lesson-room [hidden], .tl-room-board [hidden] { display: none; }
.tl-lesson-room:has(>.tl-room-questions[hidden]) { grid-template-columns: repeat(2,minmax(0,1fr)); }
.tl-room-column {
  box-sizing: border-box;
  display: grid;
  grid-template-rows: auto minmax(0,1fr);
  min-inline-size: 0;
  padding: var(--tl-room-space,16px);
  border: 1px solid var(--tl-room-divider,light-dark(#ddd,#262a36));
  border-radius: var(--tl-room-radius,16px);
  background: var(--lc-panel,light-dark(#fff,#181b24));
}
.tl-room-column>h2 {
  margin: 0 0 12px;
  padding-block-end: 12px;
  border-block-end: 1px solid var(--tl-room-divider,light-dark(#ddd,#262a36));
  color: var(--lc-text,light-dark(#1a1a1a,#e6e8ee));
  font-size: var(--tl-room-heading-size,19px);
  line-height: var(--lh-28,28px);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.tl-room-body { min-inline-size: 0; min-block-size: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.tl-room-image, .tl-room-notes { display: flex; flex-direction: column; gap: 12px; }
.tl-room-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tl-room-actions :is(button,a) { max-inline-size: 100%; white-space: normal; }
.tl-room-image [data-room-image-link]:not([hidden]) { display: block; flex: 1; min-block-size: 0; }
.tl-room-image img { display: block; inline-size: 100%; block-size: 100%; object-fit: contain; object-position: center top; }
.tl-room-status { margin: 0; color: var(--text-muted,var(--muted,#555)); font-size: 14px; line-height: var(--lh-20,20px); }
.tl-room-status:empty { display: none; }
.tl-room-notes { position: relative; }
.tl-room-notes [data-room-notes-loading] { position: absolute; inset: 0; margin: 0; padding: 12px; border: 1px solid var(--tl-room-divider,light-dark(#ddd,#262a36)); border-radius: var(--tl-room-radius,16px); }
.tl-room-notes iframe { inline-size: 100%; min-block-size: 0; flex: 1; border: 0; }
.tl-room-board-frame { margin: 0; background: transparent; block-size: 100dvh; overflow: hidden; }
body.tl-room-board-frame .lesson-wrap .board.tl-room-board { position: static; padding: 0; max-block-size: 100dvh; overflow-y: auto; overscroll-behavior: contain; }
.tl-room-board .board-ta { min-block-size: 220px; }
.tl-room-board #boardDraft textarea { box-sizing: border-box; inline-size: 100%; }
#spa-region:has(.tl-lesson-room:not([hidden])) .tabs-bar,
#spa-region:has(.tl-lesson-room:not([hidden])) #lessonSwitchStatus,
.st-workspace:has(>.tl-lesson-room:not([hidden]))>.main-grid,
.app:has(>.tl-lesson-room:not([hidden]))>#spa-region { display: none; }
.app:has(>.tl-lesson-room:not([hidden])) { max-inline-size: none; }
/* Desktop cards occupy the full workspace. The call owns no grid track. */
@media (width > 600px) {
  .tl-lesson-room {
    grid-template-rows: minmax(var(--tl-room-column-min,300px),1fr);
    block-size: max(var(--tl-room-column-min,300px),calc(100dvh - var(--tl-room-top,104px) - var(--tl-room-floor,106px)));
  }
  .tl-room-call-dock { display: none; }
}
/* The narrow desktop room retains a readable camera and the standard control row. */
@media (600px < width <= 700px) and (height > 460px) {
  body:has(.tl-lesson-room:not([hidden])):not(.tl-game-open):not(:has(#lessonStage.ls-open,.cs-share:not([hidden]))) .call-fw.managed {
    --call-video-size: 150px;
  }
}
/* Allow the bottom of the teacher's columns to scroll above the fixed lesson toolbar. */
@media (width > 600px) and (max-height: 800px) {
  .tl-lesson-room[data-room-role="teacher"] { margin-block-end: var(--tl-room-floor,106px); }
}
.tl-room-announcement { position: absolute; clip-path: inset(50%); }
@media (max-width: 600px) {
  body:has(.tl-lesson-room:not([hidden])):not(.tl-game-open):not(:has(#lessonStage.ls-open,.cs-share:not([hidden]))) .call-fw.managed {
    position: relative;
    inset: auto !important;
    margin-inline-start: auto;
  }
  .tl-room-call-dock { grid-column: 1 / -1; min-inline-size: 0; min-block-size: var(--tl-room-dock-block,64px); }
  .tl-room-call-dock .call-fw.managed {
    --call-video-size: var(--tl-room-dock-block,64px);
    display: flex;
    align-items: center;
    gap: var(--call-control-gap,12px);
    inline-size: max-content;
    max-inline-size: 100%;
  }
  .tl-room-call-dock .call-fw.managed .call-fw-media { flex: none; margin-inline-end: 0; }
  .tl-room-call-dock .call-fw.managed .call-controls { margin-block-start: 0; }
  .tl-room-call-dock .call-fw.managed .call-fw-state {
    position: static;
    color: var(--lc-text,light-dark(#1a1a1a,#e6e8ee));
    font-size: 12px;
    line-height: var(--lh-20,20px);
    text-shadow: none;
  }
  .tl-room-call-dock .call-fw.managed .call-fw-state::after { content: none; }
}

/* Keep the existing learner rail and its popover usable over lesson/share (140/141),
   below the question feed (145) and the call window (150). */
body:has(.tl-lesson-room[data-room-role="student"]:not([hidden])):has(#lessonStage.ls-open,.cs-share:not([hidden])) .st-workspace .st-tools { z-index: 143; }
body:has(.tl-lesson-room[data-room-role="student"]:not([hidden])):has(#lessonStage.ls-open,.cs-share:not([hidden])) .st-dictionary { z-index: 144; }

/* The feed retains its own content styles. Only its host geometry changes. */
.tl-room-questions { min-inline-size: 0; min-block-size: 0; display: grid; }
.tl-room-questions > .hq-panel {
  position: relative;
  z-index: auto;
  width: auto;
  min-width: 0;
  max-width: none;
  min-height: 0;
  max-height: none;
}
