/* The app's main grid owns the sidebar/header offsets, exactly once. */
#app[data-view="live"] { overflow: hidden; }
#app[data-view="live"] > main { min-width: 0; overflow: hidden; }
#app[data-view="live"] .live-view {
  position: absolute;
  inset: 0;
  height: 100%;
  width: 100%;
  min-width: 0;
  padding: 16px 24px 24px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--paper);
}
#app[data-view="live"] .session-header {
  grid-template-columns: minmax(0,1fr) auto;
  min-height: 46px;
  gap: 18px;
  padding: 0 0 14px;
  border: 0;
  background: transparent;
}
#app[data-view="live"] .session-context { min-width: 0; gap: 12px; }
#app[data-view="live"] .session-context > strong { font-family: var(--sans); font-size: 13px; font-weight: 550; max-width: 240px; }
#app[data-view="live"] .live-mode-switcher { position: relative; top: auto; left: auto; transform: none; margin-left: auto; flex-shrink: 0; }
#app[data-view="live"] .teaching-mode-pill { min-height: 34px; padding: 8px 12px; font-size: 11px; font-weight: 600; }
#app[data-view="live"] .live-mode-menu { right: 0; left: auto; transform: none; width: min(370px,calc(100vw - 40px)); }
#app[data-view="live"] .live-mode-menu::before { left: auto; right: 28px; }
#app[data-view="live"] .session-meta { gap: 10px; }
#app[data-view="live"] .session-meta .language-switch { display: none; }
#app[data-view="live"] .session-meta time { font-size: 12px; font-weight: 550; }
#app[data-view="live"] .live-workspace { height: auto; min-width: 0; gap: 12px; }
#app[data-view="live"] .session-primary-column { gap: 8px; }
#app[data-view="live"] .camera-panel { border-radius: 14px; }
#app[data-view="live"] .session-transcript-panel, #app[data-view="live"] .board-panel { border: 1px solid var(--line); border-radius: 14px; }
#app[data-view="live"] .session-transcript-header { min-height: 56px; padding: 12px 16px; gap: 10px; flex-wrap: wrap; }
#app[data-view="live"] .session-transcript-header strong { font-family: var(--sans); font-size: 14px; font-weight: 600; }
#app[data-view="live"] .session-transcript-header .eyebrow { font-size: 9px; margin-bottom: 4px; }
#app[data-view="live"] .transcript-save-state { font-size: 9px; letter-spacing: .04em; }
#app[data-view="live"] .voice-state { font-size: 10px; padding: 5px 8px; min-height: 26px; box-shadow: none; }
#app[data-view="live"] .session-transcript-panel .transcript-list { padding: 12px 16px; }
#app[data-view="live"] .live-chat-composer { padding: 10px 12px 12px; }
#app[data-view="live"] .live-chat-composer textarea { font-size: 14px; }
#app[data-view="live"] .board-header { min-height: 64px; padding: 14px 16px; }
#app[data-view="live"] .board-header strong { font-family: var(--sans); font-size: 14px; font-weight: 600; }
#app[data-view="live"] .board-empty strong { font-size: 22px; line-height: 1.3; }
#app[data-view="live"] .board-empty p { font-size: 13px; line-height: 1.6; }
#app[data-view="live"] .board-empty .button { min-height: 36px; font-size: 13px; }
#app[data-view="live"] .board-empty .text-link { margin-top: 10px; font-size: 11px; }
#app[data-view="live"] .session-controls { max-width: calc(100% - 24px); bottom: 12px; padding: 6px; border-radius: 12px; }
#app[data-view="live"] .session-controls-body { min-width: 0; overflow-x: auto; }
#app[data-view="live"] .control-button span { font-size: 9px; font-weight: 550; line-height: 1.25; }
#app[data-view="live"] .detection-status { top: 14px; left: 14px; font-size: 11px; }
#app[data-view="live"] .camera-fallback { inset: 58px 16px 88px; padding: 10px; }
#app[data-view="live"] .camera-panel.controls-collapsed .camera-fallback { bottom: 64px; }
#app[data-view="live"] .camera-fallback strong { font-family: var(--sans); font-size: 17px; font-weight: 600; }
#app[data-view="live"] .camera-fallback p { font-size: 12px; }
#app[data-view="live"] .exam-tray { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; }
/* Narrower camera panels: the grade/exam banner sits under the detection pill instead of colliding with it, and
   the no-camera placeholder starts below it, keeping only its heading and upload button (the banner says what to show). */
@container camera-workspace (max-width: 959px) {
  #app[data-view="live"] .camera-mode-banner { top: 66px; right: auto; left: 14px; width: max-content; max-width: calc(100% - 28px); flex-wrap: wrap; justify-content: space-between; row-gap: 4px; transform: none; }
  #app[data-view="live"] .camera-mode-banner > span { flex: 1 1 0; min-width: 9em; }
  #app[data-view="live"] .camera-panel:has(> .camera-mode-banner:not([hidden])) .camera-fallback { top: 128px; }
  #app[data-view="live"] .camera-panel:has(> .camera-mode-banner:not([hidden])) .camera-fallback > :is(svg, p) { display: none; }
  #app[data-view="live"] .camera-panel:has(> .camera-mode-banner:not([hidden])) .camera-fallback strong { margin-bottom: 12px; }
}
@container camera-workspace (max-width: 959px) and (max-height: 340px) {
  #app[data-view="live"] .camera-panel:has(> .camera-mode-banner:not([hidden])) .camera-fallback strong { display: none; }
}
@media(max-width:1150px) {
  #app[data-view="live"] .live-view { padding: 12px 16px 16px; }
  #app[data-view="live"] .live-pill { display: none; }
  #app[data-view="live"] .session-context > strong { max-width: 170px; }
  #app[data-view="live"] .transcript-save-state { display: none; }
}
@media(max-width:780px) {
  #app[data-view="live"] .live-view { padding: 8px 12px 12px; }
  #app[data-view="live"] .session-header { min-height: 42px; padding-bottom: 8px; gap: 8px; }
  #app[data-view="live"] .session-context > strong { display: none; }
  #app[data-view="live"] .live-mode-switcher { margin-left: 0; }
  #app[data-view="live"] .live-mode-menu { position: fixed; top: 116px; left: 12px; right: 12px; width: auto; }
  #app[data-view="live"] .live-mode-menu::before { display: none; }
  /* The header's stacking context traps the menu below the fixed board sheet (z-index 45) while it is open. */
  #app[data-view="live"] .session-header:has(#live-mode-menu:not([hidden])) { z-index: 50; }
  #app[data-view="live"] .live-workspace { height: 100%; }
  #app[data-view="live"] .session-primary-column { grid-template-rows: minmax(280px,42dvh) 0 minmax(350px,1fr); height: 100%; padding-bottom: 8px; }
  #app[data-view="live"] .camera-panel { min-height: 280px; }
  #app[data-view="live"] .session-transcript-panel { min-height: 350px; }
  #app[data-view="live"] .board-panel { border-radius: 16px 16px 0 0; }
  #app[data-view="live"] .board-restore { top: 12px; right: 12px; }
  #app[data-view="live"] .session-controls { width: calc(100% - 16px); max-width: calc(100% - 16px); bottom: 8px; }
  #app[data-view="live"] .session-controls.collapsed { width: auto; }
}

@container camera-workspace (max-width: 430px) {
  #app[data-view="live"] .control-button { min-width: 44px; padding-inline: 4px; }
  #app[data-view="live"] .control-button.voice-tutor-button { min-width: 64px; }
  #app[data-view="live"] .control-button span { max-width: 62px; }
  #app[data-view="live"] .session-controls-body { gap: 4px; }
}
@media(max-width:480px) {
  #app[data-view="live"] .control-button { min-width: 44px; height: 53px; padding-inline: 4px; }
  #app[data-view="live"] .control-button.voice-tutor-button { min-width: 64px; }
  #app[data-view="live"] .control-button span { display: block; max-width: 62px; font-size: 8px; }
  #app[data-view="live"] .session-controls-body { gap: 4px; }
}

/* Active teaching owns the whole viewport; navigation returns only on exit. */
#app[data-view="live"] { padding-left:0;min-height:0;height:100dvh;transition:none; }
#app[data-view="live"] > .workspace-sidebar,
#app[data-view="live"] > .dashboard-header,
#app[data-view="live"] > .sidebar-backdrop { display:none !important; }
#app[data-view="live"] > main { position:relative;height:100%; }
#app[data-view="live"] .live-view { position:fixed;inset:0;height:100dvh;width:100%; }
.session-exit { display:inline-flex;align-items:center;gap:7px;padding:8px 12px;min-height:34px;border:1px solid #d7ded2;border-radius:9px;background:#fffdf8;color:#28533b;font:550 11px/1.4 var(--sans);cursor:pointer; }
.session-exit svg { width:14px;height:14px; }
.session-exit:hover { background:#e8eee3; }
.session-exit:focus-visible { outline:3px solid #a7c7ad;outline-offset:3px; }
@media(max-width:780px) { .session-exit { padding:8px; }.session-exit span { display:none; } }
@media(max-width:780px) { #app[data-view="live"] .live-mode-menu { top:58px; } }

/* Dark theme: the camera panel stays dark in both themes, so give it an edge against the dark page. */
:root[data-theme="dark"] #app[data-view="live"] .camera-panel { box-shadow: 0 0 0 1px var(--color-border-strong); }
:root[data-theme="dark"] .session-exit { border-color: var(--color-border-strong); background: var(--color-surface); color: var(--color-brand-strong); }
:root[data-theme="dark"] .session-exit:hover { background: var(--color-action-secondary-hover); }
:root[data-theme="dark"] .session-exit:focus-visible { outline-color: var(--color-focus-ring); }
