:root {
  color-scheme: light;
  --ink: #142945;
  --muted: #506882;
  --blue: #235bcd;
  --blue-dark: #1645a5;
  --pale: #eaf1ff;
  --line: #dce5f1;
  --bg: #f4f7fc;
  --white: #fff;
  --green: #126340;
  --red: #a72c3b;
  --radius: 16px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; }
.site-footer {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 18px;
  padding: 12px max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  border-top: 1px solid var(--line); background: var(--white); color: var(--muted);
  font-size: .8rem; line-height: 1.6; text-align: center;
}
.site-footer a { display: inline-block; padding-block: 4px; color: inherit; text-underline-offset: 3px; }
button, select, input, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled, select:disabled { cursor: not-allowed; opacity: .55; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid #6b9afe; outline-offset: 2px;
}
button, input, select, textarea { min-height: 44px; }
a { color: var(--blue-dark); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.55rem, 2.6vw, 2.1rem); line-height: 1.25; letter-spacing: -.045em; }
h2 { font-size: 1.26rem; line-height: 1.4; }
h3 { font-size: 1rem; line-height: 1.45; }
small, .muted { color: var(--muted); }
[hidden] { display: none !important; }

.boot { min-height: 100dvh; display: grid; place-items: center; color: var(--muted); }
.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 730; font-size: 1.2rem; letter-spacing: -.025em; }
.brand img { width: 35px; height: 35px; border-radius: 8px; }
.icon { width: 20px; height: 20px; flex: 0 0 20px; vertical-align: middle; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--white);
  color: var(--ink); font-weight: 630; line-height: 1.35; text-decoration: none; text-align: center;
}
.btn:hover:not(:disabled) { background: #edf3ff; border-color: #b8cbed; }
.btn.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn.primary:hover:not(:disabled) { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn.quiet { border-color: transparent; background: transparent; }
.btn.danger { color: var(--red); background: #fff7f7; border-color: #f1ccd1; }
.btn.compact { padding: 7px 10px; min-height: 38px; font-size: .88rem; }
.btn[aria-pressed=true] { background: var(--pale); color: var(--blue-dark); border-color: #9ab7f1; }
.icon-button { padding-inline: 10px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 999px;
  color: #3e5877; background: #edf2f8; white-space: nowrap; font-size: .81rem; font-weight: 650;
}
.pill.live { color: var(--green); background: #e0f5ea; }
.pill.live::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #218759; }
.pill.cancelled { color: var(--red); background: #ffedef; }
.pill.scheduled { color: var(--blue-dark); background: var(--pale); }

.login-layout { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); }
.login-side {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: clamp(32px, 6vw, 92px); color: white; position: relative; overflow: hidden;
  background: radial-gradient(ellipse at 110% 88%, #2f67ca, transparent 65%), #142d52;
}
.login-side::after, .intro::after {
  content: ""; position: absolute; pointer-events: none; height: 390px; width: 390px;
  border: 1px solid #c2dbff35; box-shadow: 0 0 0 38px #a1c4ff19, 0 0 0 76px #a1c4ff18;
  border-radius: 50%; bottom: -162px; right: -68px;
}
.login-copy, .login-side .brand { position: relative; z-index: 1; }
.login-copy h1 { font-size: clamp(2.15rem, 4.15vw, 4rem); letter-spacing: -.075em; margin-bottom: 16px; }
.login-copy p { color: #e0ebfc; font-size: 1.12rem; line-height: 1.85; max-width: 360px; }
.login-copy { margin-block: auto; padding-block: clamp(32px, 5vw, 64px); }
.login-main { display: grid; align-items: center; justify-items: center; padding: 36px 24px; }
.login-card { width: min(100%, 422px); }
.login-card h2 { font-size: 1.85rem; margin-bottom: 5px; }
.stack { display: grid; gap: 16px; }
.login-card form { margin-top: 24px; }
.field { display: grid; gap: 7px; font-weight: 650; font-size: .92rem; }
input, select, textarea {
  color: var(--ink); border: 1px solid #cbd8eb; border-radius: 8px; background: var(--white); padding: 9px 11px;
  width: 100%; min-width: 0; accent-color: var(--blue);
}
input::placeholder, textarea::placeholder { color: #6c8096; }
input[type=checkbox] { min-height: auto; width: 17px; height: 17px; margin: 0; }
input[type=color] { width: 44px; padding: 5px; }
textarea { resize: vertical; min-height: 105px; }
.demo-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; margin-top: 11px; }
.demo-login { margin-top: 23px; padding-top: 18px; border-top: 1px solid var(--line); }
.message { color: var(--red); font-size: .9rem; line-height: 1.5; }

.shell { display: grid; grid-template-columns: 221px minmax(0, 1fr); min-height: 100dvh; }
.sidebar { display: flex; flex-direction: column; gap: 30px; padding: 24px 17px; background: #fff; border-right: 1px solid var(--line); position: sticky; top: 0; height: 100dvh; }
.sidebar > .brand { margin: 1px 8px 0; }
.nav { display: grid; gap: 6px; }
.nav-item { justify-content: flex-start; text-align: left; padding: 10px 11px; }
.nav-item[aria-current=page] { background: var(--pale); color: var(--blue-dark); }
.workspace { min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px clamp(18px, 3.1vw, 42px); background: #fff; border-bottom: 1px solid var(--line); min-height: 66px; }
.topbar-title { font-size: .95rem; color: var(--muted); }
.topbar .brand { display: none; }
.account { display: flex; align-items: center; gap: 10px; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; background: #e6efff; font-size: .87rem; color: #214eac; font-weight: 800; }
.account-name { font-size: .92rem; font-weight: 740; }
.account-role { display: block; font-size: .74rem; color: var(--muted); margin-top: 1px; }
.content { width: min(100%, 1450px); margin: 0 auto; padding: clamp(18px, 3.1vw, 42px); }
.intro {
  background: linear-gradient(110deg, #15335a, #24589b); color: #fff; padding: clamp(22px, 3.1vw, 41px);
  border-radius: var(--radius); position: relative; overflow: hidden;
}
.intro > * { position: relative; z-index: 1; }
.intro p { color: #e2edff; margin-top: 11px; line-height: 1.65; }
.intro .btn { margin-top: 18px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.metric, .panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.metric { padding: 17px 19px; display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; }
.metric-icon { display: grid; place-items: center; color: var(--blue); background: #edf3ff; width: 38px; height: 38px; border-radius: 10px; }
.metric-value { font-size: 1.46rem; line-height: 1.1; font-weight: 780; margin-top: 3px; }
.metric-label { font-size: .83rem; color: var(--muted); }
.panel { margin-top: 20px; min-width: 0; }
.panel-heading, .page-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-heading { padding: 17px 19px; border-bottom: 1px solid var(--line); }
.heading-detail { margin-top: 5px; color: var(--muted); font-size: .87rem; line-height: 1.5; }
.table-wrap { overflow: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; }
thead { background: #f9fbff; color: var(--muted); }
th, td { padding: 12px 16px; border-bottom: 1px solid var(--line); }
th { white-space: nowrap; font-size: .79rem; font-weight: 720; }
td { font-size: .88rem; vertical-align: middle; line-height: 1.6; }
tbody tr:last-child td { border-bottom: 0; }
td.course-name { min-width: 150px; }
td.date { min-width: 170px; }
td:last-child { text-align: right; }
.table-actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.lesson-list, .info-list { list-style: none; margin: 0; padding: 0; }
.lesson-row, .info-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 19px; border-bottom: 1px solid var(--line); }
.lesson-row:last-child, .info-row:last-child { border-bottom: none; }
.lesson-row p, .info-row p { color: var(--muted); font-size: .86rem; line-height: 1.55; margin-top: 4px; white-space: pre-wrap; }
.lesson-row .pill { margin: 4px 0 0; }
.lesson-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.empty { padding: 26px 19px; line-height: 1.6; color: var(--muted); }
.form-body { padding: 19px; }
.form-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.form-columns .full { grid-column: 1 / -1; }
.checkbox-list { display: flex; flex-wrap: wrap; gap: 8px; }
.check { min-height: 42px; display: inline-flex; align-items: center; gap: 7px; background: #eff4fc; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.form-actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; }

.classroom { min-height: 100dvh; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.room-header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; background: #142945;
  color: white; padding: 12px clamp(12px, 2.2vw, 28px);
}
.room-header h1 { font-size: 1.2rem; letter-spacing: -.01em; }
.room-header .meta { color: #ccd9ec; font-size: .84rem; margin-top: 2px; }
.room-header .btn.quiet { color: #fff; }
.room-header .btn.quiet:hover { background: #284467; border-color: #496581; }
.room-header > div { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.room-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(232px, 25%); gap: 14px;
  padding: 14px clamp(12px, 2.2vw, 28px); width: min(100%, 1650px); margin: auto;
}
.room-panel { min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.board-toolbar, .media-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.board-toolbar strong { margin-right: auto; }
.board-stage { padding: 9px; background: #eaf0f8; }
.board-sheet { position: relative; aspect-ratio: 16 / 9; background: #fff; border-radius: 8px; overflow: hidden; }
.board-sheet img, .board-sheet canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.board-sheet img { object-fit: contain; }
.board-sheet canvas.editable { touch-action: none; cursor: crosshair; }
.board-note, .media-note { padding: 10px; color: var(--muted); font-size: .84rem; line-height: 1.5; }
.room-aside { display: grid; align-content: start; gap: 12px; min-width: 0; }
.room-panel h2 { font-size: 1rem; padding: 11px 12px; border-bottom: 1px solid var(--line); }
.stream-list { display: grid; gap: 8px; padding: 9px; }
.stream { position: relative; display: grid; min-width: 0; aspect-ratio: 16/9; background: #203452; color: #fff; border-radius: 8px; overflow: hidden; }
.stream video { width: 100%; height: 100%; position: absolute; inset: 0; object-fit: contain; }
.stream .stream-label { align-self: end; justify-self: start; margin: 6px; z-index: 1; padding: 3px 6px; background: #122035e6; font-size: .79rem; border-radius: 5px; }
.stream .fallback { place-self: center; color: #dbe6f6; font-size: .83rem; padding-bottom: 14px; }
.camera-field { padding: 9px 10px; }
.roster { padding: 0; margin: 0; list-style: none; }
.roster li { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 11px; border-bottom: 1px solid var(--line); font-size: .88rem; }
.roster li:last-child { border-bottom: 0; }
.raised { color: #84530c; font-weight: 750; }

[data-client-role=teacher] .classroom :is(.btn.compact, .tool-field) { min-height: 44px; }
[data-client-role=teacher] .board-toolbar button { min-width: 44px; }
@media (orientation: portrait) {
  [data-client-role=teacher] .room-grid { grid-template-columns: minmax(0, 1fr); }
}

.notices { position: fixed; bottom: max(12px, env(safe-area-inset-bottom)); right: 12px; left: 12px; z-index: 10; display: grid; justify-items: end; gap: 7px; pointer-events: none; }
.notice { max-width: min(100%, 460px); background: #163450; color: #fff; padding: 11px 15px; border-radius: 10px; box-shadow: 0 4px 15px #1d355335; line-height: 1.5; }
.notice.error { background: #942536; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 173px minmax(0, 1fr); }
  .sidebar { padding-inline: 11px; }
  .metric { padding: 12px; }
  .room-grid { grid-template-columns: minmax(0, 1fr) minmax(190px, 26%); gap: 9px; }
}
@media (max-width: 660px) {
  .login-layout { display: block; }
  .login-side { padding: 20px 22px 24px; }
  .login-copy { margin-top: 25px; padding-block: 0; }
  .login-copy h1 { margin-bottom: 5px; font-size: 2.05rem; }
  .login-copy p { font-size: .9rem; }
  .login-main { padding: 24px 18px; }
  .shell { display: flex; flex-direction: column; }
  .sidebar { position: static; order: 1; height: auto; padding: 3px 10px; border: 0; border-bottom: 1px solid var(--line); }
  .sidebar > .brand { display: none; }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .nav-item { padding: 7px 9px; font-size: .86rem; }
  .nav-item .icon { width: 16px; height: 16px; flex-basis: 16px; }
  .workspace { display: contents; }
  .topbar { order: 0; padding: 8px 11px; min-height: 58px; }
  .topbar .brand { display: inline-flex; font-size: 1.02rem; }
  .topbar .brand img { width: 29px; height: 29px; }
  .topbar-title { display: none; }
  .account { gap: 6px; }
  .account-role, .account .avatar { display: none; }
  .content { order: 2; padding: 13px 11px; }
  .metrics { gap: 6px; margin-top: 10px; }
  .metric { display: block; padding: 11px 8px; }
  .metric-icon { display: none; }
  .metric-value { font-size: 1.27rem; }
  .panel { margin-top: 12px; }
  .panel-heading, .lesson-row, .info-row, .form-body { padding-inline: 12px; }
  .lesson-row, .info-row { align-items: start; }
  .form-columns { grid-template-columns: 1fr; }
  .room-grid { grid-template-columns: minmax(0, 1fr); }
  .room-aside { grid-template-columns: minmax(0, 1fr); }
  .stream-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: no-preference) {
  .btn { transition: background-color .14s ease, border-color .14s ease; }
}
.sr-only { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap; }
.tool-field { max-width: min(100%, 215px); min-height: 38px; font-size: .87rem; }
.drawing-tools { display: inline-flex; gap: 6px; align-items: center; }
fieldset { border: 0; margin: 0; min-width: 0; padding: 0; }
fieldset legend { padding: 0 0 7px; }
.stream video.no-picture { opacity: 0; pointer-events: none; }
.stream-expand { position: absolute; top: 6px; right: 6px; z-index: 1; min-height: 34px; padding: 4px 9px; }
.camera-dialog {
  width: min(94%, 1150px); max-width: none; border: 1px solid #526885; border-radius: 14px; padding: 0;
  background: #142945; color: white; overflow: hidden;
}
.camera-dialog::backdrop { background: #122139cf; }
.camera-dialog header { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 13px; }
.camera-dialog video { display: block; width: 100%; height: min(72dvh, 650px); object-fit: contain; background: #101d31; }
