/* THE LESSON ROOM (js/lesson.js, 2026-09-02) — layout D revised, Lionel's
   pick from the six of temp/lesson-lab.html: the shared falling keys LEFT
   (the game's own board, drawn by a sub-renderer into the left half), the
   OTHER person's camera RIGHT, your own camera a movable window over the
   score, the chat a collapsible drawer bottom right, a lesson bar on top.
   The score is the game's ordinary sheet strip, pushed down by the bar
   (sheet.topInset), with the teacher's marks on a canvas laid over it. */
:root { --ls-top: 0px; --ls-board-top: 220px; }
body.lesson-on { --ls-top: 44px; }

/* the game's HUD keeps to the left half and clears the bar */
body.lesson-on.sheet-on #hud-left { top: calc(var(--sheet-h, 164px) + 32px + var(--ls-top)); }
body.lesson-on.sheet-on #hud-center { top: calc(var(--sheet-h, 164px) + 26px + var(--ls-top)); left: 25%; }
body.lesson-on.sheet-on #hud-right { top: calc(var(--sheet-h, 164px) + 32px + var(--ls-top)); right: calc(50% + 24px); }
body.lesson-on #hud-center { left: 25%; }
body.lesson-on #hud-right { right: calc(50% + 24px); }
body.lesson-on #replay-menu-btn, body.lesson-on #fs-float { display: none; }

/* ------------------------------------------------------------ the bar */
#ls-bar {
  position: fixed; left: 0; right: 0; top: 0; height: 44px; z-index: 46;
  display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: #070a16; border-bottom: 1px solid rgba(255,255,255,.1);
  font-size: 12.5px; white-space: nowrap; overflow: hidden;
}
#ls-bar > * { flex: 0 0 auto; }
#ls-bar .ls-piece { font-weight: 800; letter-spacing: .2px; max-width: 26vw; overflow: hidden; text-overflow: ellipsis; }
#ls-bar .ls-piece small { color: #9fb0c9; font-weight: 600; margin-left: 6px; }
#ls-bar .ls-pos { font-variant-numeric: tabular-nums; font-weight: 900; color: var(--cyan); letter-spacing: .5px; min-width: 64px; }
#ls-bar .ls-sep { width: 1px; height: 22px; background: rgba(255,255,255,.12); }
#ls-bar .ls-grp { display: flex; align-items: center; gap: 6px; }
#ls-bar .ls-end { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.lsb {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.14); color: #dbe8f7;
  border-radius: 8px; padding: 5px 10px; font: inherit; font-size: 12px; font-weight: 700;
  white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
}
.lsb:hover { background: rgba(255,255,255,.12); }
.lsb:disabled { opacity: .45; cursor: default; }
.lsb.on { background: rgba(52,211,255,.16); border-color: rgba(52,211,255,.5); color: #bff0ff; }
.lsb.gold { background: rgba(255,215,94,.14); border-color: rgba(255,215,94,.5); color: var(--gold); }
.lsb.rec { background: rgba(255,59,92,.14); border-color: rgba(255,59,92,.55); color: #ff9aab; font-variant-numeric: tabular-nums; }
.lsb.rec.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--red); animation: ls-blink 1.2s infinite; }
.lsb.danger { border-color: rgba(255,59,92,.5); color: #ff9aab; }
@keyframes ls-blink { 50% { opacity: .25; } }
.lsb input { width: 46px; background: rgba(0,0,0,.4); border: 1px solid rgba(255,255,255,.14); color: #fff; border-radius: 5px; padding: 1px 5px; font: inherit; font-size: 12px; text-align: center; }
#ls-bar .ls-consent { display: flex; align-items: center; gap: 7px; color: var(--g-easy, #7dffb2); font-size: 11.5px; font-weight: 700; letter-spacing: .3px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#ls-bar .ls-consent i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; flex: 0 0 auto; }
#ls-bar .ls-consent.warn { color: #ffab2e; }

/* ------------------------------------------------------- the other's face */
#ls-other {
  position: fixed; left: 50%; right: 0; top: var(--ls-board-top); bottom: 0; z-index: 4;
  background: #000; border-left: 1px solid rgba(255,255,255,.08); overflow: hidden;
}
#ls-other video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
#ls-other .ls-empty {
  position: absolute; inset: 0; display: grid; place-items: center; color: #9fb0c9;
  font-size: 15px; font-weight: 700; text-align: center; line-height: 1.6; padding: 24px;
  background: radial-gradient(ellipse 60% 60% at 50% 50%, #151b33, #0a0a14 80%);
}
#ls-other .ls-empty small { display: block; color: #6f7f99; font-weight: 600; font-size: 12.5px; }
#ls-other .ls-tag, #ls-me .ls-tag {
  position: absolute; left: 10px; bottom: 10px; display: flex; align-items: center; gap: 8px; z-index: 2;
  background: rgba(0,0,0,.55); backdrop-filter: blur(6px); border-radius: 7px; padding: 4px 9px;
  font-size: 12px; font-weight: 700; color: #fff; border-left: 3px solid var(--gold);
}
#ls-me .ls-tag { border-left-color: var(--cyan); font-size: 11px; }
.ls-tag small { color: #9fb0c9; font-weight: 600; }
.ls-tag .ls-lvl { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
.ls-tag .ls-lvl i { width: 3px; background: #7dffb2; border-radius: 1px; height: 3px; transition: height .1s; }
.ls-tag .ls-nomic { color: #ff9aab; font-weight: 800; letter-spacing: .5px; font-size: 10.5px; }
#ls-other.speaking::after { content: ""; position: absolute; inset: 0; border: 2px solid #7dffb2; pointer-events: none; }

/* -------------------------------------------------------- your own face */
#ls-me {
  position: fixed; top: calc(var(--ls-top) + 20px); right: 40px; width: 232px; height: 140px; z-index: 45;
  border-radius: 12px; overflow: hidden; background: #000; cursor: grab; touch-action: none; user-select: none;
  box-shadow: 0 10px 30px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.25);
}
#ls-me.dragging { cursor: grabbing; }
#ls-me video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
#ls-me .ls-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #6f7f99; font-size: 12px; font-weight: 700; background: linear-gradient(160deg, #10304a, #0a1a2a 70%); }
#ls-me .ls-mini { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
#ls-me:hover .ls-mini { opacity: 1; }
#ls-me .ls-mini button { width: 26px; height: 26px; border-radius: 7px; font: inherit; font-size: 13px; color: #fff; background: rgba(8,10,22,.7); border: 1px solid rgba(255,255,255,.3); cursor: pointer; }
#ls-me.small { width: 150px; height: 90px; }

/* ------------------------------------------------------------ the chat */
#ls-chat {
  position: fixed; right: 16px; bottom: 16px; width: 380px; height: 300px; z-index: 47;
  display: flex; flex-direction: column; background: rgba(13,20,38,.96);
  border: 1px solid rgba(255,255,255,.28); border-radius: 10px; overflow: hidden;
  box-shadow: 0 14px 40px rgba(0,0,0,.65); transition: height .18s, width .18s;
}
#ls-chat .ls-ch {
  display: flex; align-items: center; gap: 8px; padding: 0 10px; height: 30px; flex: 0 0 30px; cursor: pointer;
  font-size: 10.5px; font-weight: 800; letter-spacing: 1.4px; color: #9fb0c9; text-transform: uppercase;
  background: rgba(0,0,0,.25); border-bottom: 1px solid rgba(255,255,255,.1);
}
#ls-chat .ls-ch b { color: #fff; letter-spacing: .2px; text-transform: none; font-size: 12px; font-weight: 700; }
#ls-chat .ls-ch .ls-unread { display: none; background: var(--cyan); color: #003; border-radius: 9px; padding: 0 6px; font-size: 10px; letter-spacing: 0; }
#ls-chat .ls-ch .ls-fold { margin-left: auto; }
#ls-chat.collapsed { height: 32px; width: 250px; }
#ls-chat.collapsed .ls-ch { border-bottom: none; background: rgba(52,211,255,.10); }
#ls-chat.collapsed .ls-ch .ls-unread.show { display: inline-block; }
#ls-chat.collapsed .ls-log, #ls-chat.collapsed .ls-in { display: none; }
#ls-chat .ls-log { flex: 1; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; line-height: 1.4; }
#ls-chat .ls-m { max-width: 92%; padding: 6px 9px; border-radius: 9px; background: rgba(255,255,255,.06); border-left: 3px solid var(--gold); word-break: break-word; }
#ls-chat .ls-m.me { border-left-color: var(--cyan); align-self: flex-end; background: rgba(52,211,255,.10); }
#ls-chat .ls-m.sys { background: none; color: #9fb0c9; font-size: 11.5px; padding: 0 2px; font-style: italic; align-self: center; text-align: center; border: none; }
#ls-chat .ls-m.sys b { color: var(--gold); font-style: normal; }
#ls-chat .ls-m .ls-who { display: block; font-size: 10.5px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: #9fb0c9; margin-bottom: 2px; }
#ls-chat .ls-in { flex: 0 0 auto; display: flex; gap: 6px; padding: 8px; border-top: 1px solid rgba(255,255,255,.1); }
#ls-chat .ls-in input { flex: 1; min-width: 0; background: rgba(0,0,0,.4); border: 1px solid rgba(255,255,255,.14); color: #fff; border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 12.5px; }
#ls-chat .ls-in button { background: var(--cyan); color: #003; border: none; border-radius: 8px; padding: 0 12px; font: inherit; font-weight: 800; font-size: 12px; cursor: pointer; }

/* ---------------------------------------------------- the marks overlay */
#ls-marks { position: fixed; z-index: 6; pointer-events: none; }
#ls-marks.live { pointer-events: auto; cursor: crosshair; }
#ls-tools {
  position: fixed; z-index: 46; display: flex; gap: 4px; padding: 4px; border-radius: 9px;
  background: rgba(28,23,18,.92); border: 1px solid rgba(255,255,255,.2); box-shadow: 0 6px 20px rgba(0,0,0,.5);
}
#ls-tools button { width: 32px; height: 32px; border-radius: 7px; border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.08); color: #fbf5e6; font: inherit; font-size: 15px; cursor: pointer; }
#ls-tools button.on { background: var(--gold); color: #3a2a00; border-color: var(--gold); }
#ls-tools button:hover:not(.on) { background: rgba(255,255,255,.18); }

/* ------------------------------------------------------ the two screens */
#lesson-screen .panel, #lesson-gate .panel { width: min(680px, 94vw); }
.ls-form { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
.ls-h { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: #9fb0c9; text-align: left; margin: 14px 0 4px; font-weight: 800; }
.ls-form input { background: rgba(0,0,0,.4); border: 1px solid rgba(255,255,255,.18); color: #fff; border-radius: 9px; padding: 9px 12px; font: inherit; font-size: 14px; }
.ls-form .lsb { padding: 9px 12px; font-size: 13px; }
.ls-piecepick { display: flex; align-items: center; gap: 10px; color: #cfe0f5; font-size: 13.5px; }
.ls-piecepick b { color: #fff; }
.ls-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; max-height: 40vh; overflow-y: auto; text-align: left; }
.ls-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; background: rgba(255,255,255,.05); font-size: 13px; }
.ls-row .ls-rl { flex: 1; min-width: 0; }
.ls-row .ls-rl b { display: block; color: #fff; }
.ls-row .ls-rl small { color: #9fb0c9; }
.ls-row .ls-st { font-size: 10.5px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; padding: 3px 8px; border-radius: 6px; background: rgba(255,255,255,.08); color: #cfe0f5; }
.ls-row .ls-st.live { background: rgba(125,255,178,.15); color: #7dffb2; }
.ls-row .ls-st.open { background: rgba(255,215,94,.14); color: var(--gold); }
.ls-row a { color: var(--cyan); font-weight: 700; text-decoration: none; }
.ls-consent-text { text-align: left; max-width: 58ch; margin: 10px auto; color: #cfe0f5; font-size: 14px; line-height: 1.55; }
.ls-consent-text li { margin: 6px 0 6px 18px; }
.ls-consent-text b { color: #fff; }
.ls-link { display: flex; gap: 6px; margin: 10px auto; max-width: 560px; }
.ls-link input { flex: 1; background: rgba(0,0,0,.4); border: 1px solid rgba(255,255,255,.18); color: #cfe0f5; border-radius: 9px; padding: 8px 10px; font: inherit; font-size: 12.5px; }
.ls-wait { color: #9fb0c9; font-size: 13px; margin-top: 8px; }
.ls-wait i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); margin-right: 8px; animation: ls-blink 1.2s infinite; }
