/* 慧课堂 SmartClass —— 蓝色现代科技风 */
:root {
  --blue-900: #0b2e6e;
  --blue-800: #0f4cb1;
  --blue-700: #155fd0;
  --blue-600: #1f6fe5;
  --blue-500: #3b8bff;
  --blue-100: #e3efff;
  --blue-50: #f1f6ff;
  --bg: #eef3fb;
  --panel: #ffffff;
  --ink: #16263d;
  --ink-2: #5a6b85;
  --line: #d8e2f2;
  --red: #f0463f;
  --green: #18b26b;
  --amber: #f5a623;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(15, 76, 177, 0.12);
  --shadow-sm: 0 4px 14px rgba(15, 76, 177, 0.10);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }

/* ---------- 通用控件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 10px; padding: 9px 14px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all .15s ease; white-space: nowrap;
}
.btn:hover { border-color: var(--blue-500); color: var(--blue-700); background: var(--blue-50); }
.btn.primary {
  background: linear-gradient(135deg, var(--blue-600), var(--blue-800));
  color: #fff; border: none; box-shadow: 0 6px 16px rgba(31, 111, 229, .35);
}
.btn.primary:hover { filter: brightness(1.06); color: #fff; background: linear-gradient(135deg, var(--blue-600), var(--blue-800)); }
.btn.danger { background: linear-gradient(135deg, #f4604f, #d92d20); color: #fff; border: none; }
.btn.danger:hover { filter: brightness(1.05); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.active { background: var(--blue-700); border-color: var(--blue-700); color: #fff; }
.icon { width: 18px; height: 18px; flex: none; }

.input {
  width: 100%; padding: 11px 14px; font-size: 15px; border: 1px solid var(--line);
  border-radius: 10px; outline: none; transition: border .15s; background: #fff; color: var(--ink);
}
.input:focus { border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(31,111,229,.15); }

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px;
  border-radius: 999px; font-size: 13px; font-weight: 700;
}
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.live { background: #e8f8f0; color: var(--green); }
.badge.waiting { background: #fff4e0; color: var(--amber); }
.badge.paused { background: #eef1f6; color: var(--ink-2); }
.badge.ended { background: #fde8e6; color: var(--red); }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel h3 {
  margin: 0; padding: 12px 16px; font-size: 14px; color: var(--blue-900);
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px;
}
.panel .body { padding: 14px 16px; }

/* ---------- 落地页 ---------- */
.landing {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(59,139,255,.25), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(15,76,177,.22), transparent 55%),
    linear-gradient(160deg, #0b2e6e, #1450a8 55%, #1f6fe5);
}
.landing-card {
  width: 100%; max-width: 440px; background: #fff; border-radius: 20px;
  box-shadow: 0 30px 70px rgba(0,0,0,.35); padding: 34px 30px;
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.brand .logo {
  width: 46px; height: 46px; border-radius: 13px; flex: none;
  background: linear-gradient(135deg, var(--blue-600), var(--blue-900));
  display: flex; align-items: center; justify-content: center; color: #fff;
  box-shadow: 0 8px 18px rgba(15,76,177,.4);
}
.brand h1 { font-size: 24px; margin: 0; color: var(--blue-900); letter-spacing: 1px; }
.brand small { display: block; color: var(--ink-2); font-size: 12px; letter-spacing: 2px; font-weight: 600; }
.landing-sub { color: var(--ink-2); font-size: 14px; margin: 6px 0 22px; }
.tabs { display: flex; background: var(--blue-50); border-radius: 11px; padding: 4px; margin-bottom: 20px; }
.tabs button {
  flex: 1; border: none; background: transparent; padding: 10px; border-radius: 8px;
  font-size: 14px; font-weight: 700; color: var(--ink-2); cursor: pointer;
}
.tabs button.active { background: #fff; color: var(--blue-700); box-shadow: var(--shadow-sm); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.code-input { letter-spacing: 8px; text-align: center; font-size: 22px; font-weight: 700; }
.landing-foot { margin-top: 18px; font-size: 12px; color: var(--ink-2); text-align: center; line-height: 1.7; }

/* ---------- 应用骨架 ---------- */
.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 10px 18px;
  background: linear-gradient(90deg, var(--blue-900), var(--blue-700));
  color: #fff; box-shadow: 0 4px 18px rgba(11,46,110,.35); z-index: 20; flex: none;
}
.topbar .brand h1 { color: #fff; font-size: 18px; }
.topbar .brand small { color: rgba(255,255,255,.7); }
.topbar .spacer { flex: 1; }
.top-meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.code-chip {
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25);
  border-radius: 10px; padding: 6px 12px; font-weight: 700; letter-spacing: 2px; font-size: 16px;
}
.code-chip small { display: block; font-size: 10px; letter-spacing: 1px; opacity: .75; font-weight: 500; }
.topbar .btn { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); color: #fff; }
.topbar .btn:hover { background: rgba(255,255,255,.22); color: #fff; }
.live-badge.live { background: rgba(24,178,107,.25); color: #7ff0b6; }
.live-badge.waiting { background: rgba(245,166,35,.22); color: #ffd27a; }
.live-badge.paused { background: rgba(255,255,255,.16); color: #e6ecf5; }
.live-badge.ended { background: rgba(240,70,63,.25); color: #ff9d97; }

.main { flex: 1; display: flex; min-height: 0; }
.stage-wrap { flex: 1; padding: 14px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.stage {
  position: relative; flex: 1; min-height: 0; border-radius: 16px; overflow: hidden;
  background: #0d1b34; border: 1px solid var(--line); box-shadow: var(--shadow);
}
.layer { position: absolute; inset: 0; display: none; }
.layer.show { display: block; }
.layer.board-layer { background: #fff; }
.layer canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.layer video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.cam-tag {
  position: absolute; left: 12px; bottom: 12px; background: rgba(11,46,110,.72);
  color: #fff; padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  backdrop-filter: blur(4px);
}
/* 课件层 */
#cw-content { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); }
#cw-img { display: block; width: 100%; height: 100%; }
#cw-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.cw-placeholder {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 10px;
  align-items: center; justify-content: center; color: #cdd9ee; background: #0d1b34;
}
/* 激光笔红点 */
#laser-dot {
  position: absolute; width: 22px; height: 22px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 35% 35%, #ff8a80, #f0463f 60%, rgba(240,70,63,.15));
  box-shadow: 0 0 0 6px rgba(240,70,63,.18), 0 0 18px rgba(240,70,63,.8);
  transform: translate(-50%,-50%); z-index: 30; display: none;
}
/* 画中画 */
#pip-box {
  position: absolute; right: 16px; bottom: 16px; width: 200px; height: 134px; z-index: 25;
  border-radius: 12px; overflow: hidden; border: 2px solid rgba(255,255,255,.8);
  box-shadow: 0 12px 30px rgba(0,0,0,.45); background: #000; display: none;
}
#pip-box.show { display: block; }
#pip-box video { width: 100%; height: 100%; object-fit: cover; }
#pip-box .pip-tag {
  position: absolute; left: 6px; top: 6px; background: rgba(0,0,0,.5); color: #fff;
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
}
/* 状态遮罩 */
.overlay {
  position: absolute; inset: 0; z-index: 40; display: none; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; color: #fff; text-align: center;
  background: rgba(8,20,42,.82); backdrop-filter: blur(3px); padding: 20px;
}
.overlay.show { display: flex; }
.overlay .big { font-size: 22px; font-weight: 800; }
.overlay .sub { font-size: 14px; opacity: .85; }
.spinner {
  width: 46px; height: 46px; border: 4px solid rgba(255,255,255,.25); border-top-color: #fff;
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 舞台下方源切换条 */
.source-bar {
  display: flex; gap: 8px; align-items: center; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 8px 10px; box-shadow: var(--shadow-sm); flex: none;
  overflow-x: auto;
}
.source-bar .label { font-size: 13px; color: var(--ink-2); font-weight: 700; padding: 0 6px; flex: none; }
.src-btn {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line);
  background: #fff; border-radius: 10px; padding: 8px 13px; font-size: 14px; font-weight: 600;
  cursor: pointer; color: var(--ink); white-space: nowrap;
}
.src-btn:hover { border-color: var(--blue-500); color: var(--blue-700); }
.src-btn.active { background: var(--blue-700); border-color: var(--blue-700); color: #fff; }
.src-btn .st-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-2); }
.src-btn .st-dot.on { background: var(--green); }

/* 侧边栏 */
.sidebar {
  width: 340px; flex: none; padding: 14px 14px 14px 0; display: flex; flex-direction: column; gap: 12px;
  overflow-y: auto; min-height: 0;
}
.sidebar .panel { flex: none; }
.tool-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatches { display: flex; gap: 8px; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; cursor: pointer;
  box-shadow: 0 0 0 1px var(--line); transition: transform .1s;
}
.swatch:hover { transform: scale(1.1); }
.swatch.active { box-shadow: 0 0 0 3px var(--blue-700); }
/* 画笔粗细滑动条 */
.pen-size-row { gap: 8px; align-items: center; }
.pen-size-label { font-size: 12px; color: var(--ink-2); font-weight: 600; flex: none; }
.pen-slider {
  -webkit-appearance: none; appearance: none; flex: 1; min-width: 90px;
  height: 6px; border-radius: 999px; outline: none; cursor: pointer;
  background: linear-gradient(to right, var(--blue-100), var(--blue-500));
}
.pen-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 3px solid var(--blue-700);
  box-shadow: 0 2px 6px rgba(15,76,177,.35); cursor: pointer;
}
.pen-slider::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 3px solid var(--blue-700); cursor: pointer;
}
.pen-size-preview {
  display: inline-block; flex: none; border-radius: 50%;
  background: var(--red); box-shadow: 0 0 0 1px var(--line);
  width: 6px; height: 6px; margin: 0 2px;
}

/* 通用隐藏 */
.hide { display: none !important; }

/* 符号库 */
.symbol-groups { display: flex; flex-direction: column; gap: 4px; padding-right: 2px; }
.sym-group { border: 1px solid var(--line); border-radius: 9px; background: #fff; overflow: hidden; }
.sym-group-head {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border: none; background: var(--blue-50);
  cursor: pointer; font-size: 13px; font-weight: 700; color: var(--blue-900);
}
.sym-group-head:hover { background: var(--blue-100); }
.sym-group-head .chev {
  width: 14px; height: 14px; flex: none;
  transform: rotate(90deg); transition: transform .15s ease;
}
.sym-group:not(.expanded) .sym-group-head .chev { transform: rotate(0deg); }
.sym-grid {
  display: none; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 4px;
  padding: 8px;
}
.sym-group.expanded .sym-grid { display: grid; }
.sym-btn {
  height: 34px; min-width: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: 7px; background: #fff;
  cursor: pointer; font-size: 17px; line-height: 1; color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-family: "Segoe UI Symbol", "Cambria Math", "Segoe UI Emoji", "Microsoft YaHei", serif;
  transition: all .12s; padding: 0 2px; box-sizing: border-box;
  text-overflow: ellipsis; white-space: nowrap;
}
.sym-btn:hover { border-color: var(--blue-500); background: var(--blue-50); transform: translateY(-1px); }
.sym-btn.active { border-color: var(--blue-700); background: var(--blue-700); color: #fff; box-shadow: 0 3px 10px rgba(31,111,229,.35); }
.sym-btn.wide { font-size: 11px; font-weight: 700; font-family: inherit; grid-column: span 2; letter-spacing: -.2px; }
.sym-btn.dev-btn { grid-column: span 2; height: 40px; padding: 4px; flex-direction: column; gap: 2px; }
.sym-btn.dev-btn svg { width: 22px; height: 22px; color: var(--blue-700); }
.sym-btn.dev-btn::after {
  content: attr(data-code);
  font-size: 9px; font-weight: 700; color: var(--ink-2);
  font-family: "Segoe UI","Microsoft YaHei",sans-serif; line-height: 1;
}
.sym-btn.dev-btn:hover svg { color: var(--blue-900); }
.symbol-hint {
  margin-top: 8px; font-size: 12px; color: var(--blue-800);
  background: var(--blue-50); border: 1px solid var(--blue-100);
  border-radius: 8px; padding: 7px 10px; line-height: 1.5;
}
.symbol-hint b { font-size: 15px; color: var(--red); padding: 0 2px; }
canvas.stamping { cursor: copy; }

/* 二维码弹窗：仅显示一个码时居中 */
.qr-grid.single { display: flex; }
.qr-grid.single .qr-cell { width: 100%; max-width: 300px; margin: 0 auto; }
.pip-opts { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px;
  font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink-2);
}
.pill.active { background: var(--blue-700); color: #fff; border-color: var(--blue-700); }

/* 课件缩略图 */
.pages { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.page-thumb {
  position: relative; flex: none; width: 96px; border-radius: 9px; overflow: hidden;
  border: 2px solid var(--line); cursor: pointer; background: #f0f3f9;
}
.page-thumb.active { border-color: var(--blue-700); box-shadow: 0 0 0 2px rgba(31,111,229,.3); }
.page-thumb img { width: 100%; display: block; }
.page-thumb .pn {
  position: absolute; left: 0; right: 0; bottom: 0; background: rgba(11,46,110,.75);
  color: #fff; font-size: 11px; text-align: center; padding: 2px;
}

/* 名单 */
.roster { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.roster-item {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 9px;
  background: var(--blue-50); font-size: 14px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none; color: #fff; font-size: 13px;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-800));
}
.roster-item .rname { flex: 1; font-weight: 600; }
.roster-item .rrole { font-size: 11px; color: var(--ink-2); background: #fff; padding: 2px 8px; border-radius: 999px; }
.empty-note { color: var(--ink-2); font-size: 13px; text-align: center; padding: 14px 0; }

/* 二维码弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(8,20,42,.6); z-index: 100; display: none;
  align-items: center; justify-content: center; padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 18px; padding: 26px; max-width: 380px; width: 100%;
  text-align: center; box-shadow: 0 30px 70px rgba(0,0,0,.4);
}
.modal h2 { margin: 0 0 6px; color: var(--blue-900); }
.modal p { color: var(--ink-2); font-size: 14px; margin: 6px 0 16px; line-height: 1.6; }
.modal img.qr { width: 220px; height: 220px; border-radius: 12px; border: 1px solid var(--line); }
.modal .link-box {
  margin-top: 14px; background: var(--blue-50); border: 1px dashed var(--blue-500);
  border-radius: 10px; padding: 10px; font-size: 13px; color: var(--blue-800);
  word-break: break-all; cursor: pointer;
}
.qr-grid { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.qr-cell { text-align: center; }
.qr-cell .qr-title { font-weight: 800; color: var(--blue-900); margin-bottom: 8px; font-size: 15px; }
.qr-cell .qr-note { font-size: 12px; color: var(--ink-2); margin-top: 8px; max-width: 220px; }
@media (max-width: 560px) { .modal img.qr { width: 170px; height: 170px; } }

/* 手机端 */
.phone-app { height: 100vh; background: #0a1730; color: #fff; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.phone-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.phone-head {
  position: relative; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; background: linear-gradient(180deg, rgba(5,15,35,.85), transparent);
}
.phone-head .title { font-weight: 800; font-size: 17px; }
.phone-head .status { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 13px; }
.phone-controls {
  position: relative; z-index: 5; margin-top: auto; padding: 22px 16px calc(26px + env(safe-area-inset-bottom));
  display: flex; justify-content: center; gap: 22px; background: linear-gradient(0deg, rgba(5,15,35,.9), transparent);
}
.pbtn {
  width: 62px; height: 62px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.16); color: #fff; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px); border: 2px solid rgba(255,255,255,.25);
}
.pbtn.main { width: 74px; height: 74px; background: linear-gradient(135deg, var(--blue-500), var(--blue-800)); }
.pbtn.off { background: rgba(240,70,63,.85); }
.pbtn .icon { width: 28px; height: 28px; }
.phone-center {
  position: relative; z-index: 4; flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 24px;
}
.phone-msg {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); z-index: 4;
  background: rgba(8,22,48,.7); padding: 10px 18px; border-radius: 999px; font-size: 14px;
  display: none; align-items: center; gap: 8px;
}
.phone-msg.show { display: flex; }

/* 提示 toast */
#toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%) translateY(20px);
  background: rgba(11,46,110,.95); color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 14px; z-index: 200; opacity: 0; transition: all .25s; pointer-events: none;
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 录制按钮 ---------- */
#btn-record .rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-2); display: inline-block; margin-right: 4px; }
#btn-record.recording { background: linear-gradient(135deg, #f4604f, #d92d20); color: #fff; border: none; }
#btn-record.recording .rec-dot { background: #fff; animation: rec-pulse 1s infinite; }
@keyframes rec-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* 响应式 */
@media (max-width: 980px) {
  .main { flex-direction: column; }
  .sidebar { width: 100%; padding: 0 12px 12px; flex: none; max-height: 42vh; }
  .stage-wrap { padding: 10px; }
}
@media (max-width: 640px) {
  .topbar { gap: 8px; padding: 8px 10px; flex-wrap: wrap; }
  .topbar .brand h1 { font-size: 15px; }
  .hide-sm { display: none !important; }
  #pip-box { width: 130px; height: 90px; right: 10px; bottom: 10px; }
}
