/* Only an authenticated instructor gets the extra row; the learner layout stays unchanged. */
body.instructor-unlocked {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) var(--instructor-notes-height, 200px) auto;
}
body.instructor-unlocked > footer { grid-row: 4; }
body.instructor-minimized { grid-template-rows: auto minmax(0, 1fr) 52px auto; }

#instructor-panel {
  position: relative;
  grid-row: 3;
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 7px;
  padding: 8px 16px;
  border-top: 2px solid var(--orange);
  background: var(--bg);
  color: var(--ink);
}
.instructor-resize { position:absolute; top:-7px; left:0; right:0; height:12px; z-index:5; cursor:ns-resize; touch-action:none; }
.instructor-resize::after { content:""; display:block; width:54px; height:4px; margin:4px auto; border-radius:4px; background:var(--orange); }
.instructor-resize:hover::after, .instructor-resize:focus-visible::after { background:var(--title); }
.instructor-resize:focus-visible { outline:2px solid var(--blue); outline-offset:0; }
.instructor-resizing { cursor:ns-resize; user-select:none; }
.instructor-bar, .instructor-controls, .instructor-dialog-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}
.instructor-bar { flex-wrap: nowrap; }
.instructor-bar h2 {
  flex: 0 1 auto;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
}
.instructor-bar button { flex-shrink: 0; }
.instructor-time { flex-shrink: 0; white-space: nowrap; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted); }
.instructor-save-status { margin-left: auto; font-size: 12px; color: var(--ok); }
.instructor-error { color: var(--err); }
.instructor-audience-layout { display: flex; align-items: center; gap: 5px; font-size: 12px; }
.instructor-audience-layout select {
  padding: 3px 5px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
}
.instructor-audience-status { font-size: 12px; color: var(--muted); }
.instructor-editor {
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  padding: 12px 16px;
  border: 1px solid var(--rule);
  border-radius: 5px;
  color: var(--ink);
  background: var(--code-bg);
  font-family: var(--font);
  line-height: 1.6;
  tab-size: 2;
}
.instructor-editor:focus { outline: 2px solid var(--blue); outline-offset: -2px; }
.instructor-message { margin: 0; color: var(--muted); font-size: 12px; }
#instructor-panel.minimized { grid-template-rows: 1fr; }
#instructor-panel.minimized > :not(.instructor-bar) { display: none; }
#instructor-panel [hidden] { display: none !important; }
.instructor-dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 24px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 16px 70px #0005;
}
.instructor-dialog::backdrop { background: #0007; }
.instructor-dialog h2 { margin: 0 0 12px; font-size: 22px; }
.instructor-dialog p { line-height: 1.5; }
.instructor-dialog label { display: grid; gap: 8px; }
.instructor-dialog input {
  width: 100%;
  padding: 9px 12px;
  color: var(--ink);
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 4px;
  font: inherit;
}
.instructor-dialog-actions { justify-content: flex-end; }
.instructor-login-status { min-height: 1.5em; color: var(--err); }
.instructor-discard { color: var(--err); }
.instructor-private button:disabled { opacity: .5; cursor: default; }
@media (max-width: 700px) {
  body.instructor-unlocked:not(.instructor-minimized) {
    grid-template-rows: auto minmax(0, 1fr) minmax(0, var(--instructor-notes-height, 200px)) auto;
  }
  body.instructor-unlocked > header { grid-area: 1 / 1; }
  body.instructor-unlocked > main { grid-area: 2 / 1; }
  #instructor-panel { padding-inline: 10px; }
  #instructor-panel:not(.minimized) {
    grid-area: 1 / 1 / 4;
    height: var(--instructor-notes-height, 200px);
    align-self: end;
    padding-top: 20px;
    z-index: 30;
  }
  .instructor-resize { top: 0; height: 20px; }
  .instructor-resize::after { margin-top: 6px; }
  body.instructor-notes-full > :is(header, main, .helper-launch, .helper) { visibility: hidden; }
  .instructor-bar { flex-wrap: wrap; }
  .instructor-bar h2 { flex: 1 0 100%; }
  body.instructor-minimized { grid-template-rows: auto minmax(0, 1fr) auto auto; }
  .instructor-save-status { max-width: 130px; }
  .instructor-controls .tool-btn { font-size: 12px; }
}
@media print { .instructor-private { display: none !important; } }

/* The instructor always keeps both teaching panes; audience layout is independent. */
body.instructor-unlocked #present { display:none; }
body.instructor-unlocked main { grid-template-columns:minmax(0,11fr) minmax(0,9fr); }
body.instructor-unlocked .cells-pane { display:block; }
/* Keep the helper launcher clear of the private script editor. */
body.instructor-unlocked:not(.instructor-minimized) .helper-launch { bottom:calc(var(--instructor-notes-height, 200px) + 92px); }
