[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
:root { --ink: #11192f; --blue: #2858ec; --paper: #fffdf8; --line: #dadfea; --muted: #475473; }
body { margin: 0; color: var(--ink); background: var(--paper); font: 1rem/1.5 system-ui, sans-serif; }
:focus-visible { outline: 3px solid #2045c2; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
.shell { width: min(100% - 2rem, 70rem); margin-inline: auto; }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: 1.25rem; border-bottom: 1px solid var(--line); }
.site-header strong { font-size: .95rem; letter-spacing: .045em; }
.site-header em { font-style: normal; color: var(--blue); }
.site-header span { color: var(--muted); font-size: .88rem; }
.intro { padding-block: 2rem 1.3rem; }
.intro h1 { font-size: clamp(1.8rem, 4vw, 2.85rem); letter-spacing: -.055em; line-height: 1.12; }
.intro p { margin-top: .55rem; color: var(--muted); }
.classroom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(17.5rem, 21rem); gap: 1rem; align-items: start; padding-bottom: 2rem; }
.lesson, .video-card, .room-card { min-width: 0; border: 1px solid var(--line); border-radius: 1.15rem; background: #fff; padding: 1rem; }
.lesson-head, .video-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
h2 { font-size: 1.15rem; letter-spacing: -.025em; }
.lesson-head span { font-size: .88rem; color: var(--muted); }
.tools, .call-controls { display: flex; gap: .42rem; flex-wrap: wrap; margin-top: .7rem; }
button, input { font: inherit; min-height: 44px; border: 1px solid #aeb8d0; border-radius: .6rem; padding: .5rem .65rem; color: var(--ink); background: #fff; }
button { cursor: pointer; font-size: .92rem; font-weight: 700; }
button:disabled { cursor: default; opacity: .55; }
.tools [aria-pressed='true'] { color: #1c40b6; background: #e8eeff; border-color: #6680d8; }
.tools button:disabled { opacity: 1; }
.primary { color: white; background: var(--blue); border-color: var(--blue); width: 100%; }
.teaching-stage { margin-top: .8rem; border-radius: .8rem; background: #f3f5fc; padding: clamp(.65rem, 2vw, 1.1rem); }
.panel { display: grid; justify-items: center; align-content: center; gap: .6rem; text-align: center; min-height: 21rem; }
.panel p, .media-note, #room-status, .video-placeholder { color: var(--muted); font-size: .9rem; }
.chess-board { display: grid; grid-template: repeat(8, minmax(0, 1fr)) / repeat(8, minmax(0, 1fr)); width: min(100%, 24rem); aspect-ratio: 1; border-radius: .65rem; overflow: hidden; box-shadow: 0 2px 8px #17295524; }
.square { display: grid; place-items: center; min-width: 0; min-height: 0; background: #eaf1ff; font: clamp(1rem, 4vw, 2.4rem)/1 'Segoe UI Symbol', sans-serif; }
.square:nth-child(16n+2), .square:nth-child(16n+4), .square:nth-child(16n+6), .square:nth-child(16n+8), .square:nth-child(16n+9), .square:nth-child(16n+11), .square:nth-child(16n+13), .square:nth-child(16n+15) { background: #718ac6; }
.paper { background: #fffaf0; border-radius: .6rem; padding: 1rem; }
.paper p { max-width: 27rem; }
.equation { color: #294bc0; font-size: clamp(1.9rem, 6vw, 3.2rem); letter-spacing: -.06em; }
summary { cursor: pointer; color: #2645a9; padding: .6rem; }
.sidebar { display: grid; gap: .8rem; }
.video-stage { position: relative; margin-top: .6rem; background: #172446; aspect-ratio: 16/9; border-radius: .7rem; overflow: hidden; }
.video-placeholder { display: grid; height: 100%; place-items: center; color: #d3ddfb; text-align: center; padding: .4rem; }
video { display: block; background: #172446; object-fit: cover; }
#remote-video { width: 100%; height: 100%; }
#local-video { position: absolute; width: 32%; aspect-ratio: 4/3; right: .32rem; bottom: .32rem; border: 1px solid #fff; border-radius: .42rem; }
#video-status { font-size: .79rem; font-weight: 700; color: var(--muted); }
#video-status[data-kind='connected'] { color: #215643; }
#video-status[data-kind='error'] { color: #a13426; }
.call-controls button[aria-pressed='false'] { background: #fbeae3; border-color: #ac584d; }
.media-note, #room-status:not(:empty) { margin-top: .65rem; }
#join-form, #invite { margin-top: .8rem; }
.join-row { display: flex; gap: .4rem; margin-top: .3rem; }
.join-row input { min-width: 0; width: 100%; }
.room-card label { font-size: .9rem; }
#create-form input { width: 100%; margin-block: .3rem .6rem; }
.leave { margin-top: .7rem; color: #89372c; }

@media (hover: hover) and (pointer: fine) {
  button:hover:not(:disabled) { border-color: var(--blue); background: #eef3ff; }
  .primary:hover:not(:disabled) { background: #2045c2; }
}

@media (prefers-reduced-motion: no-preference) {
  button { transition: transform 125ms cubic-bezier(.23, 1, .32, 1); }
  button:active:not(:disabled):not(:focus-visible) { transform: scale(.97); }
}

@media (max-width: 720px) {
  .classroom { grid-template-columns: minmax(0, 1fr); }
  .sidebar { grid-row: 1; }
  body.in-room .sidebar { position: sticky; z-index: 2; top: 0; }
  body.in-room .video-card { margin-left: auto; width: min(100%, 14rem); padding: .6rem; box-shadow: 0 3px 14px #17295524; }
  body.in-room .sidebar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  body.in-room .video-card { grid-column: 2; }
  body.in-room .room-card { grid-column: 1; grid-row: 1; padding: .6rem; }
  body.in-room .room-card .join-row { flex-wrap: wrap; }
  .call-controls button { padding-inline: .35rem; font-size: .77rem; }
  .square { font-size: clamp(1.3rem, 6vw, 2.4rem); }
  .panel { min-height: 17rem; }
}
