:root {
  color-scheme: light;
  --ink: #263746;
  --muted: #6f7f89;
  --line: #dce6eb;
  --paper: #ffffff;
  --canvas: #f5f7fa;
  --blue: #2b5876;
  --blue-light: #e9f2f8;
  --green: #4caf50;
  --danger: #ae4a4a;
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; color: var(--ink); background: linear-gradient(145deg, #f4f8fb, #eef3f1); }
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.shell { width: min(1440px, 100%); margin: 0 auto; padding: 32px clamp(16px, 3vw, 48px) 60px; }
.panel { min-height: calc(100vh - 92px); display: flex; flex-direction: column; justify-content: center; }
.landing-panel { max-width: 1000px; margin: auto; width: 100%; }
.eyebrow { color: var(--blue); letter-spacing: .14em; font-size: 12px; font-weight: 800; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(30px, 4vw, 48px); line-height: 1.15; }
h2 { margin-bottom: 8px; font-size: 20px; }
.lead { max-width: 650px; color: var(--muted); font-size: 18px; line-height: 1.7; margin-bottom: 30px; }
.landing-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.join-only .landing-grid { grid-template-columns: minmax(0, 560px); justify-content: center; }
.card, .triangle-card { background: rgba(255,255,255,.92); border: 1px solid rgba(213, 226, 232, .95); border-radius: 20px; box-shadow: 0 15px 35px rgba(43,88,118,.08); }
.card { padding: 22px; }
.action-card { display: flex; flex-direction: column; gap: 12px; }
.action-card p { color: var(--muted); line-height: 1.65; min-height: 52px; margin-bottom: 4px; }
.card-kicker { color: var(--blue); font-size: 13px; font-weight: 800; }
label { display: flex; flex-direction: column; gap: 7px; color: var(--ink); font-size: 14px; font-weight: 700; }
input, select { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 10px; background: #fbfdfe; padding: 9px 12px; color: var(--ink); }
input:focus { outline: 3px solid rgba(43,88,118,.15); border-color: var(--blue); }
select:focus { outline: 3px solid rgba(43,88,118,.15); border-color: var(--blue); }
.button { border: 1px solid transparent; border-radius: 11px; padding: 10px 15px; min-height: 42px; font-weight: 800; transition: .16s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(.98); }
.button:disabled { cursor: not-allowed; opacity: .45; }
.button.primary { color: white; background: var(--blue); }
.button.secondary { color: #225a42; background: #dff2e4; }
.button.combine { color: white; background: #2196f3; }
.button.danger { color: white; background: var(--danger); }
.button.ghost { color: var(--blue); background: transparent; border-color: var(--line); }
.button.small { min-height: 34px; padding: 7px 11px; font-size: 13px; }
.status-line { min-height: 24px; color: var(--muted); margin: 18px 0 0; }
.resume-box { margin-top: 18px; padding: 14px 16px; color: var(--blue); background: var(--blue-light); border-radius: 12px; }
.resume-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.resume-row + .resume-row { margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(43,88,118,.15); }
.join-context { padding: 10px 12px; color: #225a42; background: #e8f5eb; border-radius: 10px; font-size: 13px; line-height: 1.5; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; }
.topbar h1 { font-size: clamp(26px, 3vw, 38px); margin-bottom: 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.connection-pill { border-radius: 999px; padding: 7px 11px; font-size: 13px; font-weight: 800; }
.connection-pill.online { color: #1e6b43; background: #dff2e4; }
.connection-pill.offline { color: #8c5a26; background: #fff0d6; }
.teacher-meta { display: grid; grid-template-columns: 1fr auto minmax(300px, 1.2fr); align-items: center; gap: 24px; margin-bottom: 22px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.55; }
.tiny { font-size: 11px; margin: 7px 0 0; }
.join-code { display: block; color: var(--blue); font-size: 32px; letter-spacing: .14em; margin-top: 5px; }
.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.qr-wrap img { width: 108px; height: 108px; border-radius: 9px; background: white; border: 1px solid var(--line); }
.observe-controls { min-width: 0; }
.segmented { display: flex; gap: 7px; margin-top: 7px; flex-wrap: wrap; }
.segmented .active { color: white; border-color: var(--blue); background: var(--blue); }
.works-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.teacher-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, .8fr); gap: 22px; align-items: start; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-heading h2 { margin-bottom: 2px; }
.section-heading p { margin-bottom: 0; }
.student-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.student-card { position: relative; padding: 14px; border: 2px solid transparent; background: var(--paper); border-radius: 16px; box-shadow: 0 9px 22px rgba(43,88,118,.06); cursor: pointer; }
.student-card.selected { border-color: var(--blue); }
.student-card.offline { opacity: .68; }
.student-card.unstable { border-color: #edc675; }
.student-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 7px; }
.student-card-head strong { font-size: 17px; }
.student-card-head span { color: var(--muted); font-size: 11px; }
.submission-badge { display: inline-flex; align-items: center; width: fit-content; margin: 0 0 8px; padding: 4px 8px; border-radius: 999px; color: #315f45; background: #e4f3e8; font-size: 11px; font-weight: 800; }
.submission-badge.empty { color: var(--muted); background: #eef2f4; }
.student-card canvas, #teacher-canvas, #student-canvas { display: block; width: 100%; height: auto; background: white; border-radius: 10px; box-shadow: inset 0 0 0 1px #e3e9ec; }
#student-canvas { touch-action: none; }
.student-card canvas, .student-generic-preview { aspect-ratio: 8 / 5; }
.student-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 5px; margin-top: 8px; color: var(--muted); font-size: 11px; }
.student-card-actions { display: flex; gap: 5px; }
.mini-action { border: 0; padding: 2px 4px; background: transparent; color: var(--blue); font-size: 11px; }
.mini-action.danger-text { color: var(--danger); }
.spotlight-panel { position: sticky; top: 16px; }
.spotlight-panel { min-height: 300px; }
.empty-overlay { color: var(--muted); text-align: center; padding: 24px 0; }
.student-meta { display: flex; gap: clamp(18px, 5vw, 70px); margin-bottom: 22px; }
.student-meta > div { display: flex; flex-direction: column; gap: 4px; }
.student-meta strong { font-size: 18px; }
.triangle-card { padding: clamp(12px, 2vw, 22px); }
.control-panel { margin-bottom: 18px; background: white; padding: 15px 20px; border-radius: 12px; box-shadow: 0 4px 6px rgba(0,0,0,.08); }
.inputs { display: flex; align-items: end; justify-content: space-around; flex-wrap: wrap; gap: 10px; }
.inputs label { flex-direction: row; align-items: center; white-space: nowrap; }
.inputs label input { width: 70px; min-height: 38px; padding: 6px 8px; }
.inputs .red { color: #e53935; }.inputs .green { color: #43a047; }.inputs .blue { color: #1e88e5; }
.connector-control { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); color: #344054; font-size: 14px; font-weight: 700; }
.sync-switch { position: relative; display: inline-block; width: 52px; height: 28px; flex: 0 0 auto; }
.sync-switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.sync-switch span { position: absolute; inset: 0; cursor: pointer; border-radius: 999px; background: #c7ced8; transition: .2s; }
.sync-switch span::before { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: .2s; }
.sync-switch input:checked + span { background: #7b61ff; }
.sync-switch input:checked + span::before { transform: translateX(24px); }
.sync-switch input:focus-visible + span { outline: 3px solid rgba(43,88,118,.22); outline-offset: 2px; }
.instructions { max-width: 800px; margin: 15px auto 0; color: #555; font-size: 14px; line-height: 1.7; }
.generic-student-card { height: calc(100vh - 230px); min-height: 560px; overflow: hidden; background: white; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 15px 35px rgba(43,88,118,.08); }
.generic-student-card iframe { display: block; width: 100%; height: 100%; border: 0; background: white; }
.work-submit { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 18px; }
.work-submit strong { display: block; margin-bottom: 4px; }
.work-submit p { margin: 0; }
.generic-replay-surface { position: relative; width: 100%; min-height: 220px; overflow: hidden; color: var(--muted); background: white; border-radius: 10px; box-shadow: inset 0 0 0 1px #e3e9ec; }
.student-generic-preview { min-height: 0; }
#teacher-generic-preview { aspect-ratio: 8 / 5; }
.generic-replay-surface .replayer-wrapper iframe { display: block; border: 0; max-width: none; pointer-events: none !important; }
.focus-open { overflow: hidden; }
.focus-overlay { position: fixed; inset: 0; z-index: 1000; display: grid; grid-template-rows: auto minmax(0, 1fr); padding: clamp(12px, 2vw, 24px); color: var(--ink); background: rgba(238, 244, 247, .98); }
.focus-bar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 4px 4px 14px; }
.focus-bar h2 { margin: 3px 0 2px; font-size: clamp(22px, 3vw, 34px); }
.focus-bar p { margin: 0; }
.focus-close { display: inline-flex; align-items: center; gap: 7px; min-width: 44px; min-height: 44px; padding: 8px 12px; border: 1px solid #cbd9df; border-radius: 999px; color: var(--ink); background: rgba(255,255,255,.96); box-shadow: 0 8px 22px rgba(43,88,118,.12); font-weight: 800; }
.focus-close:hover { background: white; transform: translateY(-1px); }
.focus-close span { font-size: 13px; }
.focus-stage { position: relative; min-height: 0; display: grid; place-items: center; overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 20px 50px rgba(43,88,118,.13); }
#focus-canvas { display: block; width: min(100%, 1280px); max-height: 100%; object-fit: contain; background: white; }
.focus-replay { width: 100%; height: 100%; min-height: 0; border-radius: 20px; box-shadow: none; }
.focus-empty { color: var(--muted); font-size: 16px; }

@media (max-width: 900px) {
  .teacher-meta, .teacher-layout { grid-template-columns: 1fr; }
  .spotlight-panel { position: static; }
}
@media (max-width: 650px) {
  .landing-grid { grid-template-columns: 1fr; }
  .topbar, .student-meta { align-items: flex-start; flex-direction: column; }
  .work-submit, .works-actions, .resume-row { align-items: stretch; flex-direction: column; }
  .inputs { justify-content: flex-start; }
  .inputs label { width: 100%; justify-content: space-between; }
  .inputs .button { width: 100%; }
  .shell { padding-top: 20px; }
  .generic-student-card { height: calc(100vh - 190px); min-height: 460px; }
  .focus-close span { display: none; }
}
