* { box-sizing: border-box; margin: 0; }
:root {
  --bg: #0f172a; --panel: #1e293b; --line: #334155;
  --txt: #e2e8f0; --mut: #94a3b8;
  --pri: #2563eb; --ok: #16a34a; --dgr: #dc2626;
}
body {
  font-family: "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg); color: var(--txt);
  height: 100vh; display: flex; flex-direction: column;
}
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px; border-bottom: 1px solid var(--line);
}
h1 { font-size: 18px; font-weight: 600; }
#conn { display: flex; align-items: center; gap: 8px; color: var(--mut); font-size: 13px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--dgr); }
#secwarn { background: #7c2d12; color: #fed7aa; padding: 8px 20px; font-size: 13px; }

#app { flex: 1; display: grid; grid-template-columns: 300px 1fr; gap: 16px; padding: 16px; overflow: hidden; }
#sidebar { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; cursor: pointer;
}
.card.sel { border-color: var(--pri); }
.card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.card-actions { display: flex; gap: 8px; }

.btn {
  border: 0; border-radius: 8px; padding: 8px 14px; font-size: 14px;
  cursor: pointer; background: #475569; color: #fff;
}
.btn.primary { background: var(--pri); }
.btn.danger { background: var(--dgr); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; }
.badge.on { background: #14532d; color: #bbf7d0; }
.badge.ring { background: #78350f; color: #fde68a; }

#panel { overflow-y: auto; }
.placeholder { color: var(--mut); padding: 40px; text-align: center; }
.block {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 16px; margin-bottom: 16px;
}
.block-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.count { color: var(--mut); font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--bg); color: var(--txt);
  border-radius: 8px; padding: 6px 12px; font-size: 14px; cursor: pointer;
}
.chip.no { border-color: #7f1d1d; color: #fca5a5; }
.chip.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.chips.dim .chip { cursor: default; opacity: .6; }
.hint { color: var(--mut); font-size: 13px; margin-top: 8px; }
.absent { color: #fca5a5; font-weight: 600; }
.sumline { font-size: 15px; line-height: 1.8; }

.overlay {
  position: fixed; inset: 0; background: rgba(2, 6, 23, .7);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 20px; width: 440px;
  display: flex; flex-direction: column; gap: 12px;
}
.modal h3 { font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
#login .modal { width: 340px; }
input, select {
  background: var(--bg); color: var(--txt); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px; font-size: 14px;
}
textarea {
  background: var(--bg); color: var(--txt); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px; font-size: 15px;
  min-height: 260px; resize: vertical; font-family: inherit;
}
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 8px; z-index: 60; font-size: 14px;
}
.hidden { display: none !important; }

/* ---------- 移动端适配 ---------- */
@media (max-width: 760px) {
  body { height: 100dvh; }
  header { padding: 10px 14px; }
  h1 { font-size: 15px; }
  #secwarn { font-size: 12px; }
  /* 单列：整页滚动，侧栏教室卡片横向滑动 */
  #app { grid-template-columns: 1fr; gap: 10px; padding: 10px; overflow: visible; }
  #sidebar {
    flex-direction: row; overflow-x: auto; overflow-y: hidden;
    padding-bottom: 4px; -webkit-overflow-scrolling: touch;
  }
  .card { min-width: 210px; flex: 0 0 auto; }
  .card-actions { display: flex; }
  .card-actions .btn { flex: 1; }
  #panel { overflow: visible; }
  /* 触控目标加大 */
  .btn { padding: 12px 14px; font-size: 15px; }
  .chip { padding: 10px 14px; font-size: 15px; }
  .block { padding: 12px; margin-bottom: 12px; }
  .block-head { gap: 8px; }
  .sumline { font-size: 14px; }
  .modal { width: min(92vw, 440px); }
  #login .modal { width: min(92vw, 340px); }
  textarea { min-height: 40vh; }
  #toast { font-size: 13px; bottom: 12px; max-width: 90vw; width: max-content; }
#tapListen {
  position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%);
  z-index: 55; background: var(--pri); color: #fff; border: 0;
  border-radius: 26px; padding: 14px 24px; font-size: 16px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
}
}
