/* ================= 郑外新枫杨 · 班级连线（手机端） =================
   品牌色取自校徽：赭红（地球底）、深紫与亮蓝（三笔飞白）、中性灰（外环）。
   赭红只用于「主操作与选中态」，数据曲线用亮蓝、告警用正红，
   避免整页泛红导致真正的提醒失去分量。
==================================================================== */
:root {
  --paper: #f7f4ef;
  --card: #ffffff;
  --ink: #241f1c;
  --ink2: #5d544e;
  --mute: #9a9188;
  --line: #e8e0d4;

  --brand: #a63a22;      /* 校徽赭红 */
  --brand-d: #8a2f1b;
  --brand-l: #f8ebe5;
  --brand-2: #2e1a6b;    /* 校徽深紫 */
  --brand-3: #1b93ce;    /* 校徽亮蓝 */

  --ok: #2f7d5b;
  --ok-l: #eaf3ee;
  --amber: #b07a24;
  --red: #b5442f;

  --r: 14px;
  --sh: 0 1px 2px rgba(58, 38, 24, .04), 0 8px 20px rgba(58, 38, 24, .05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.pad { padding: 14px 16px 88px; }
.muted { color: var(--mute); }
.small { font-size: 12.5px; }
.row { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.sp { flex: 1; }

/* 页面容器 */
.page { min-height: 100vh; }
.page:not(.hidden) { animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* 登录页：顶部一层极淡赭红，作为校徽的「光」 */
body[data-page="auth"] {
  background:
    radial-gradient(118% 52% at 50% -8%, #fbeee7 0%, rgba(251, 238, 231, 0) 64%),
    var(--paper);
}

/* 顶栏 */
.bar {
  display: flex; align-items: center; gap: 8px;
  padding: 13px 12px 10px; position: sticky; top: 0; z-index: 5;
  background: rgba(247, 244, 239, .93); backdrop-filter: blur(10px);
}
.bar h2 { font-size: 17px; font-weight: 600; margin: 0; flex: 1; text-align: center; letter-spacing: .4px; }
.bar .sp { width: 34px; }
.icon-btn {
  border: none; background: transparent; color: var(--ink2);
  font-size: 20px; width: 34px; height: 34px; border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-family: inherit;
}
.icon-btn:active { background: var(--brand-l); }

/* 首页顶栏：校徽 + 校名 + 页面标题（三行信息压在两行里） */
.bar-brand { align-items: center; gap: 11px; padding: 14px 14px 11px; }
.bar-brand .bar-logo {
  width: 36px; height: 36px; flex: none; object-fit: contain;
  filter: drop-shadow(0 3px 8px rgba(122, 45, 25, .14));
}
.bar-brand .bar-title { flex: 1; min-width: 0; }
.bar-brand .bar-school {
  display: block; font-size: 10.5px; letter-spacing: 1.6px;
  color: var(--brand); font-weight: 600;
}
.bar-brand h2 {
  flex: none; text-align: left; font-size: 19px; letter-spacing: .8px;
  margin: 1px 0 0; line-height: 1.25;
}

/* 品牌头（登录页） */
.brand { text-align: center; padding: 30px 0 22px; }
.brand-logo {
  display: block; width: 92px; height: 92px; margin: 0 auto 15px;
  object-fit: contain;
  filter: drop-shadow(0 8px 18px rgba(122, 45, 25, .18));
}
.brand-school {
  font-size: 12.5px; letter-spacing: 3px; color: var(--ink2);
  font-weight: 600; text-indent: 3px;
}
.brand h1 {
  font-size: 26px; margin: 9px 0 0; letter-spacing: 7px;
  font-weight: 700; text-indent: 7px; color: var(--ink);
}
.brand-en {
  font-size: 10px; letter-spacing: 3.4px; color: var(--mute);
  margin-top: 7px; text-indent: 3.4px;
}
.brand-rule {
  width: 46px; height: 2px; margin: 15px auto 0; border-radius: 2px;
  background: linear-gradient(90deg, var(--brand-2), var(--brand), var(--brand-3));
  opacity: .55;
}
.brand p { margin: 13px 0 0; font-size: 13px; color: var(--ink2); letter-spacing: .3px; }

/* 分段控件 */
.seg { display: flex; background: #ece5da; border-radius: 11px; padding: 3px; margin-bottom: 18px; }
.seg button {
  flex: 1; border: none; background: transparent; padding: 9px 0; border-radius: 9px;
  font-size: 14px; color: var(--ink2); cursor: pointer; font-family: inherit;
}
.seg button.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(58, 38, 24, .08); }
.seg.sm { margin: 0; margin-bottom: 0; }
.seg.sm button { padding: 7px 0; font-size: 13px; }

/* 表单 */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; color: var(--ink2); margin-bottom: 7px; }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number], input[type=datetime-local], input[type=time], input[type=date], textarea {
  width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 11px;
  background: var(--card); color: var(--ink); font: inherit; outline: none;
  transition: border-color .16s, box-shadow .16s;
}
input:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(166, 58, 34, .1);
}
textarea { resize: vertical; min-height: 120px; }

/* 按钮 */
.btn {
  width: 100%; padding: 13px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; font-size: 15px; cursor: pointer;
}
.btn.primary {
  background: linear-gradient(180deg, #b3442a, var(--brand-d));
  border-color: var(--brand-d); color: #fff; font-weight: 600;
  box-shadow: 0 6px 16px rgba(166, 58, 34, .2);
}
.btn.ghost { background: transparent; }
.btn.sm { width: auto; padding: 9px 16px; font-size: 13.5px; }
.btn:disabled { opacity: .45; box-shadow: none; }
.btn:active { transform: scale(.99); }
.link { border: none; background: none; color: var(--brand); font: inherit; font-size: 13px; cursor: pointer; padding: 0; }
/* 喊话进行中：按钮反色 + 呼吸，明确表示麦克风正开着 */
#video-talk.on-air {
  color: #fff; background: var(--brand);
  padding: 4px 10px; border-radius: 999px;
  animation: talk-breathe 1.4s ease-in-out infinite;
}
@keyframes talk-breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}
.hint { font-size: 12.5px; color: var(--mute); line-height: 1.6; margin: 12px 0 0; }

/* 卡片 */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px; margin-bottom: 12px; box-shadow: var(--sh);
}
.card.tight { padding: 12px 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 14px; font-weight: 600; }
.tag {
  font-size: 11.5px; font-weight: 500; color: var(--brand);
  background: var(--brand-l); padding: 3px 9px; border-radius: 20px;
}

/* 班级卡片 */
.cls-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 15px; margin-bottom: 10px; cursor: pointer; box-shadow: var(--sh);
}
.cls-card:active { border-color: #e0cfc3; }
.cls-card .dot { width: 8px; height: 8px; border-radius: 50%; background: #d6cfc5; flex: none; }
.cls-card .dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(47, 125, 91, .16); }
.cls-card .meta { flex: 1; min-width: 0; }
.cls-card .nm { font-weight: 600; font-size: 15.5px; }
.cls-card .sub { font-size: 12.5px; color: var(--mute); margin-top: 2px; }
.empty { text-align: center; color: var(--mute); padding: 46px 0; font-size: 13.5px; }

/* 状态条 */
.statusline {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--ink2); padding: 0 2px 12px;
}
.statusline .pill { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 4px 11px; }
.statusline .pill b { color: var(--ink); font-weight: 600; }

/* 三宫格动作 */
.trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.trio-btn {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 15px 6px; display: flex; flex-direction: column; gap: 3px; align-items: center;
  font-family: inherit; cursor: pointer; box-shadow: var(--sh);
}
.trio-btn b { font-size: 14.5px; font-weight: 600; }
.trio-btn small { font-size: 11.5px; color: var(--mute); }
.trio-btn:active { background: var(--brand-l); border-color: #eed6cb; }

/* 音量 */
/* 数值与单位必须留在同一行，纵向 flex 会把「dB」挤到下一行 */
.db-now { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.05; }
.db-now .val { display: inline-flex; align-items: baseline; }
.db-now b { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.db-now i { font-style: normal; font-size: 12px; color: var(--mute); margin-left: 2px; }
/* 具体时刻：老师要能分辨这个数字是刚刚的还是教室离线前最后一次的 */
.db-now em { font-style: normal; font-size: 11px; color: var(--mute); margin-top: 3px; font-variant-numeric: tabular-nums; }
.db-now.stale b, .db-now.stale i { color: var(--mute); }
.chart-wrap { height: 108px; margin: 4px -2px 8px; }
#db-chart { width: 100%; height: 100%; display: block; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chips button {
  border: 1px solid var(--line); background: var(--card); color: var(--ink2);
  border-radius: 20px; padding: 6px 12px; font: inherit; font-size: 12.5px; cursor: pointer;
}
.chips button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chips.sm button { padding: 5px 10px; font-size: 12px; }
.monitor-tag { margin-top: 10px; font-size: 12.5px; color: var(--ink2); }

/* 消息预览 */
.msg-preview .m { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.msg-preview .m:first-child { border-top: none; }
.msg-preview .m .t { color: var(--mute); font-size: 11.5px; flex: none; width: 62px; }
.msg-preview .m .c { flex: 1; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 视频 */
.video-box { position: relative; background: #14100e; border-radius: var(--r); overflow: hidden; aspect-ratio: 16 / 10; touch-action: none; }
/* 缩放层：只包画面，不包占位文案与水印，否则放大时文字一起被拉变形 */
.video-pan { position: absolute; inset: 0; transform-origin: 0 0; will-change: transform; }
.video-pan video { width: 100%; height: 100%; object-fit: contain; background: #14100e; display: block; }
/* 跨网络中继画面：P2P 打不通时用约 2.5 帧/秒的连续抓拍顶上 */
.snap {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; background: #14100e; display: none;
}
.zoom-badge {
  position: absolute; right: 10px; top: 10px; padding: 3px 9px; border: 0;
  border-radius: 999px; font-size: 11px; color: #fff; background: rgba(0, 0, 0, .55);
  font-variant-numeric: tabular-nums;
}
/* iOS Safari 不支持元素级 requestFullscreen，用伪全屏兜底 */
.video-box.faux-full {
  position: fixed; inset: 0; z-index: 900; border-radius: 0;
  aspect-ratio: auto; display: flex; align-items: center; justify-content: center;
}
.video-box.faux-full .video-pan { position: relative; inset: auto; width: 100%; height: 100%; }
.video-ph {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #9a8a80; font-size: 13px; text-align: center; padding: 0 24px;
}
.watermark { position: absolute; left: 10px; bottom: 8px; color: rgba(255, 255, 255, .5); font-size: 11px; pointer-events: none; }

/* 额度条 */
.bar-track { height: 6px; background: #ece5da; border-radius: 6px; overflow: hidden; margin-top: 8px; }
.bar-track i { display: block; height: 100%; background: var(--brand); border-radius: 6px; }

/* 开关 */
.switch-row { display: flex; align-items: center; justify-content: space-between; font-size: 14px; margin: 6px 0 0; }
.switch-row input { display: none; }
/* i 默认是行内元素，不设 display 时 width/height 无效，开关会"看不见" */
.switch-row i {
  display: block;
  width: 44px; height: 26px; border-radius: 20px; background: #ddd5c9; position: relative;
  transition: background .18s; flex: none;
}
.switch-row label { display: flex; align-items: center; cursor: pointer; }
.switch-row i::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: transform .18s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .16);
}
.switch-row input:checked + i { background: var(--brand); }
.switch-row input:checked + i::after { transform: translateX(18px); }
/* 无权限时置灰：任课老师看得见状态，但点不动 */
.switch-row input:disabled + i { opacity: .45; }
.switch-row input:disabled ~ * { pointer-events: none; }
.sw-label { display: flex; align-items: center; }

/* 我的 */
.me-row { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 600; margin-bottom: 4px; }

/* 关于学校：只出现在「我的」页，作为归属标识 */
.school-card { display: flex; align-items: center; gap: 13px; }
.school-card img {
  width: 46px; height: 46px; flex: none; object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(122, 45, 25, .14));
}
.school-card .sc-name { font-size: 14px; font-weight: 600; letter-spacing: .3px; }
.school-card .sc-sub { font-size: 11.5px; color: var(--mute); margin-top: 3px; letter-spacing: .6px; }

/* 好友 */
.friend-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.friend-item:first-child { border-top: none; }
.avatar {
  width: 38px; height: 38px; border-radius: 12px; background: var(--brand-l); color: var(--brand);
  display: flex; align-items: center; justify-content: center; font-weight: 600; flex: none;
}
.friend-item .info { flex: 1; min-width: 0; }
.friend-item .info .nm { font-size: 14.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-item .info .sub { font-size: 12px; color: var(--mute); }
/* 传输记录状态（服务器不再提供下载，只显示投递状态） */
.pill {
  flex: none; display: inline-block; font-size: 11.5px; line-height: 1.4;
  padding: 4px 10px; border-radius: 20px; border: 1px solid var(--line);
  color: var(--mute); background: var(--card); white-space: nowrap;
}
.pill.ok { border-color: var(--ok); color: var(--ok); background: var(--ok-l); }

/* 底部导航 */
/* 文字放大到 15px：原来 12.5px 在手机上一眼扫不到，用户明确要求"字大一点、更容易看到" */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex;
  background: rgba(255, 255, 255, .97); border-top: 1px solid var(--line);
  padding: 7px 0 calc(7px + env(safe-area-inset-bottom)); backdrop-filter: blur(10px); z-index: 20;
}
.tabbar button {
  flex: 1; border: none; background: none; font: inherit; font-size: 15px;
  letter-spacing: .5px;
  color: var(--mute); padding: 8px 0; cursor: pointer; position: relative;
}
.tabbar button.on { color: var(--brand); font-weight: 700; }
.tabbar button.on::after {
  content: ''; position: absolute; left: 50%; top: 0; transform: translateX(-50%);
  width: 22px; height: 3px; border-radius: 3px; background: var(--brand);
}
body[data-page="auth"] .tabbar { display: none; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%) translateY(12px);
  background: rgba(36, 31, 28, .94); color: #fff; font-size: 13.5px;
  padding: 10px 18px; border-radius: 22px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; max-width: 84vw; text-align: center; z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 底部弹层 */
.mask { position: fixed; inset: 0; background: rgba(30, 22, 18, .42); z-index: 50; display: flex; align-items: flex-end; }
.sheet {
  width: 100%; background: var(--paper); border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 84vh; overflow: auto;
  animation: up .22s ease;
}
@keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet h3 { margin: 0 0 14px; font-size: 16px; }
.sheet .sheet-row { padding: 13px 0; border-top: 1px solid var(--line); font-size: 14.5px; display: flex; justify-content: space-between; align-items: center; }
.sheet .sheet-row:first-of-type { border-top: none; }

/* 定时关机：大号时间选择（替代原来的"启用药匙+重复+时间+日期"四行） */
.sd-clock {
  margin: 10px 0 4px; padding: 12px 12px 10px; border-radius: var(--r);
  background: var(--card); border: 1px solid var(--line); text-align: center;
}
.sd-clock-label { font-size: 12.5px; color: var(--mute); }
.sd-clock input[type="time"] {
  width: 100%; border: none; background: transparent; color: var(--ink);
  font: inherit; font-size: 42px; font-weight: 700; letter-spacing: 1.5px;
  text-align: center; padding: 2px 0; line-height: 1.2;
}
.sd-clock input[type="time"]::-webkit-date-and-time-value { text-align: center; }
.sd-clock-tip { font-size: 11.5px; color: var(--mute); opacity: .8; }
/* 成员页的学科输入：只改前缀署名，不改变任何权限 */
.sheet .subj {
  width: 84px;
  margin-left: 6px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--ink2);
  font: inherit;
  font-size: 13px;
  text-align: center;
}
.sheet .subj:focus { outline: none; border-color: var(--brand); color: var(--ink); }
.sheet .subj::placeholder { color: var(--mute); }
/* 教室电脑状态卡 */
.dev-status { padding-top: 2px; }
.dev-status .dev-line {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 13.5px;
  color: var(--ink2);
}
.dev-status .dev-line b { font-weight: 500; color: var(--ink); }
.dev-status .dev-line b.on { color: var(--ok); }
.dev-status .hint { margin: 6px 0 2px; }

/* 截图结果 */
.shot-img {
  width: 100%;
  border-radius: var(--r);
  display: block;
  margin-top: 8px;
  background: #14100e;
}

/* 无权限的入口 */
.trio-btn.off { opacity: .55; }
.trio-btn.off small { color: var(--amber); }

/* ===== 加入申请 / 审批 ===== */
/* 申请原因是短文本，textarea 默认 120px 太高，弹窗会被顶到屏幕外 */
.field textarea { min-height: 84px; }

.req-row {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.req-row:first-of-type { border-top: none; }
.req-main {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.req-main b { font-size: 15px; color: var(--ink); }
.req-reason {
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink2);
  word-break: break-word;
  white-space: pre-wrap;
}
.req-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
.req-actions .btn.sm {
  flex: 1;
  margin-top: 0;
}
