* { box-sizing: border-box; }

:root {
  --bg: #f6f5f4;
  --text: #1a1a1a;
  --muted: #787671;
  --red: #e03131;
  --orange: #dd5b00;
  --blue: #0075de;
  --green: #1aae39;
  --purple: #5645d4;
  --purple-pressed: #4534b3;
  --surface: #ffffff;
  --line: #e5e3df;
  --line-strong: #c8c4be;
  --shadow-card: rgba(15, 15, 15, 0.2) 0 24px 48px -8px;
  --display-font: "Inter", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans SC", sans-serif;
  --num-font: "SF Pro Display", "Segoe UI", "PingFang SC", sans-serif;
}

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--display-font);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }

.hidden { display: none !important; }

.screen {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% -20%, rgba(86, 69, 212, 0.07), transparent 55%),
    radial-gradient(90% 70% at 10% 110%, rgba(245, 215, 94, 0.12), transparent 60%),
    radial-gradient(70% 60% at 95% 100%, rgba(255, 232, 212, 0.5), transparent 60%),
    #f6f5f4;
}

.ambient {
  position: absolute;
  inset: -10%;
  background:
    radial-gradient(circle at 30% 25%, rgba(86, 69, 212, 0.06), transparent 42%),
    radial-gradient(circle at 72% 70%, rgba(42, 157, 153, 0.06), transparent 45%);
  filter: blur(20px);
  animation: ambientFloat 14s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes ambientFloat {
  from { transform: translate3d(-1.5%, -1%, 0) scale(1); }
  to { transform: translate3d(2%, 1.5%, 0) scale(1.06); }
}

/* ---------- 顶部 HUD ---------- */

.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(14px, 2.4vh, 30px) clamp(18px, 3vw, 48px);
  pointer-events: none;
  opacity: 0.92;
  transition: opacity 0.4s ease;
}
/* 播报字幕/语音时隐藏顶栏（设备名、绑定码、连接状态），避免遮挡内容 */
body.broadcasting .hud { opacity: 0; }
/* 播报时同样隐藏待机元素（设备行、绑定码行），滚动字幕模式下保持画面干净 */
body.broadcasting .idle-main { opacity: 0; }
.hud-brand { display: flex; align-items: center; gap: 12px; }
.hud-logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  color: var(--purple);
  background: rgba(86, 69, 212, 0.08);
  border: 1px solid rgba(86, 69, 212, 0.25);
}
.hud-logo svg { width: 21px; height: 21px; stroke-width: 2; }
.hud-name { font-size: clamp(14px, 1.4vw, 19px); font-weight: 600; letter-spacing: 1px; }
.hud-tag {
  font-size: clamp(10px, 0.85vw, 12px);
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 2px 9px;
  border-radius: 20px;
}
.hud-groups {
  display: flex;
  align-items: center;
  gap: 6px;
}
.hud-groups.hidden { display: none; }
.hud-pair {
  font-family: var(--num-font);
  letter-spacing: 1px;
  color: rgba(86, 69, 212, 0.8);
  border-color: rgba(86, 69, 212, 0.28);
}
.hud-status {
  display: flex; align-items: center; gap: 9px;
  font-size: clamp(11px, 0.9vw, 13px);
  color: var(--muted);
}
.conn-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #a4a097;
  box-shadow: 0 0 0 3px rgba(15, 15, 15, 0.05);
  transition: background 0.3s, box-shadow 0.3s;
}
.conn-dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(26, 174, 57, 0.16); }
.conn-dot.off { background: var(--red); box-shadow: 0 0 0 3px rgba(224, 49, 49, 0.16); }
/* ---------- 视图切换 ---------- */

.view {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.45s ease, visibility 0.45s;
}
.view.show { opacity: 1; visibility: visible; }

/* ---------- 启动遮罩 ---------- */

.start-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background:
    radial-gradient(80% 60% at 50% 20%, rgba(86, 69, 212, 0.07), transparent 60%),
    #f6f5f4;
  text-align: center;
  transition: opacity 0.5s ease, visibility 0.5s;
}
.start-overlay.gone { opacity: 0; visibility: hidden; }
.start-inner { padding: 24px; }
.start-logo {
  width: 92px; height: 92px;
  margin: 0 auto 26px;
  border-radius: 24px;
  display: grid; place-items: center;
  color: var(--purple);
  background: rgba(86, 69, 212, 0.08);
  border: 1px solid rgba(86, 69, 212, 0.25);
  box-shadow: 0 8px 24px rgba(86, 69, 212, 0.12);
}
.start-logo svg { width: 54px; height: 54px; stroke-width: 2; }
.start-inner h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 4vw, 46px);
  letter-spacing: 2px;
  font-weight: 700;
  color: var(--text);
}
.start-inner p { margin: 0 0 34px; color: var(--muted); font-size: clamp(13px, 1.4vw, 17px); letter-spacing: 1px; }
.start-btn {
  display: inline-flex; align-items: center; gap: 12px;
  height: clamp(52px, 7vh, 64px);
  padding: 0 clamp(34px, 5vw, 58px);
  border-radius: 10px;
  border: 1px solid rgba(15, 15, 15, 0.08);
  background: var(--purple);
  color: #fff;
  font-size: clamp(16px, 1.8vw, 20px);
  font-weight: 600;
  letter-spacing: 4px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(15, 15, 15, 0.1);
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
  font-family: inherit;
}
.start-btn svg { width: 20px; height: 20px; }
.start-btn:hover { background: var(--purple-pressed); transform: translateY(-2px); box-shadow: 0 16px 40px rgba(86, 69, 212, 0.28); }
.start-note { margin-top: 34px; font-size: 12px; color: #a4a097; letter-spacing: 0.5px; }

/* ---------- 配对 ---------- */

.pair-view { padding: 80px 24px 24px; }
.pair-card {
  width: min(720px, 92vw);
  padding: clamp(28px, 5vh, 54px) clamp(24px, 5vw, 60px);
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  text-align: center;
}
.pair-eyebrow {
  font-size: clamp(11px, 1vw, 13px);
  letter-spacing: 8px;
  color: var(--purple);
  margin-bottom: clamp(16px, 3vh, 30px);
}
.pair-label { font-size: clamp(12px, 1.1vw, 15px); color: var(--muted); letter-spacing: 3px; }
.pair-code {
  font-family: "SF Mono", "Consolas", monospace;
  font-size: clamp(54px, 10vw, 108px);
  font-weight: 700;
  letter-spacing: clamp(8px, 1.8vw, 18px);
  color: var(--text);
  text-shadow: 0 2px 24px rgba(86, 69, 212, 0.18);
  margin: clamp(8px, 1.5vh, 18px) 0 clamp(14px, 2.5vh, 26px);
  font-variant-numeric: tabular-nums;
}
.pair-desc {
  font-size: clamp(13px, 1.3vw, 16px);
  color: #5d5b54;
  line-height: 1.7;
  max-width: 520px;
  margin: 0 auto clamp(18px, 3vh, 30px);
}
.pair-server {
  display: inline-block;
  font-family: "SF Mono", Consolas, monospace;
  font-size: clamp(11px, 1vw, 13px);
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px dashed var(--line-strong);
  margin-bottom: clamp(16px, 3vh, 28px);
}
.pair-wait {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: clamp(12px, 1.1vw, 14px);
  color: var(--orange);
}
.pair-wait i {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--orange);
  animation: pairoPulse 1.4s ease-in-out infinite;
}
@keyframes pairoPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(221, 91, 0, 0.35); }
  50% { opacity: 0.55; box-shadow: 0 0 0 8px rgba(221, 91, 0, 0); }
}
.pair-platform { margin-top: clamp(20px, 3vh, 34px); font-size: 11px; color: #a4a097; letter-spacing: 0.5px; }

/* ---------- 待机 ---------- */

.idle-view { flex-direction: column; }
.idle-main { text-align: center; z-index: 2; transition: opacity 0.4s ease; }
.idle-device {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 8px 20px;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
  font-size: clamp(13px, 1.2vw, 16px);
  color: #37352f;
  letter-spacing: 1px;
}
.idle-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px rgba(26, 174, 57, 0.5); }
.idle-hint {
  margin-top: 14px;
  font-size: clamp(11px, 1vw, 13px);
  color: #a4a097;
  letter-spacing: 2px;
}
.idle-pair {
  margin-top: 10px;
  font-size: clamp(11px, 1vw, 13px);
  color: #a4a097;
  letter-spacing: 1px;
}
.idle-pair b {
  font-family: "SF Mono", Consolas, monospace;
  font-weight: 600;
  font-size: clamp(13px, 1.2vw, 16px);
  color: var(--purple);
  letter-spacing: 3px;
  margin: 0 2px;
}
.idle-pair span { font-size: 0.92em; }
.idle-rings { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.idle-rings span {
  position: absolute;
  left: 50%; top: 50%;
  width: 42vmin; height: 42vmin;
  margin: -21vmin 0 0 -21vmin;
  border-radius: 50%;
  border: 1px solid rgba(86, 69, 212, 0.14);
  animation: ringExpand 9s linear infinite;
}
.idle-rings span:nth-child(2) { animation-delay: 3s; }
.idle-rings span:nth-child(3) { animation-delay: 6s; }
@keyframes ringExpand {
  0% { transform: scale(0.55); opacity: 0; }
  25% { opacity: 0.9; }
  100% { transform: scale(2.6); opacity: 0; }
}

/* ---------- 播报舞台 ---------- */

.stage {
  padding: clamp(80px, 11vh, 130px) clamp(24px, 6vw, 130px) clamp(70px, 10vh, 120px);
  z-index: 5;
}
.stage-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(80% 70% at 50% 40%, rgba(86, 69, 212, 0.08), transparent 62%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.65), rgba(246, 245, 244, 0.92));
  transition: background 0.4s;
  z-index: -1;
}
.stage-top {
  position: absolute;
  top: clamp(76px, 10vh, 120px);
  left: clamp(24px, 6vw, 130px);
  right: clamp(24px, 6vw, 130px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.live {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 7px 16px;
  border-radius: 22px;
  background: rgba(86, 69, 212, 0.08);
  border: 1px solid rgba(86, 69, 212, 0.25);
  font-size: clamp(11px, 1vw, 14px);
  letter-spacing: 3px;
  color: var(--purple);
}
.live i {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--purple);
  animation: livePulse 1.1s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(86, 69, 212, 0.5); }
  50% { opacity: 0.5; box-shadow: 0 0 0 9px rgba(86, 69, 212, 0); }
}
.stage-meta { font-size: clamp(11px, 0.9vw, 13px); color: var(--muted); letter-spacing: 1px; }

.text-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
/* 美化：文字不再填满全屏，改为居中卡片（Notion 白卡） */
.shout-text {
  margin: 0;
  text-align: center;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: clamp(1px, 0.18vw, 3px);
  color: var(--text);
  text-shadow: none;
  /* 加宽卡片：短句保底有横幅感，长句最多到 1500px，比例更协调 */
  width: fit-content;
  min-width: min(54vw, 860px);
  max-width: min(90vw, 1500px);
  max-height: 74vh;
  box-sizing: border-box;
  padding: clamp(26px, 4.2vh, 58px) clamp(30px, 4.2vw, 80px);
  border-radius: clamp(14px, 1.6vw, 24px);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  word-break: break-word;
  overflow-wrap: anywhere;
  animation: textIn 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes textIn {
  from { opacity: 0; transform: translateY(26px) scale(0.97); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: none; }
}

/* 紧急样式 */
.stage.urgent .stage-bg {
  background:
    radial-gradient(80% 80% at 50% 45%, rgba(255, 55, 55, 0.35), transparent 62%),
    linear-gradient(180deg, #6d0c0c, #200305 70%, #170204);
}
.stage.urgent .shout-text {
  background: linear-gradient(180deg, rgba(90, 14, 14, 0.68), rgba(40, 6, 8, 0.76));
  border-color: rgba(255, 110, 110, 0.3);
  box-shadow: 0 28px 80px rgba(120, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  color: #fff;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.25), 0 4px 60px rgba(255, 30, 30, 0.6);
}
.stage.urgent::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 10px solid rgba(255, 60, 60, 0.55);
  box-shadow: inset 0 0 80px rgba(255, 30, 30, 0.4);
  animation: urgentBorder 1.4s ease-in-out infinite;
  pointer-events: none;
  z-index: 8;
}
@keyframes urgentBorder {
  0%, 100% { border-color: rgba(255, 60, 60, 0.3); }
  50% { border-color: rgba(255, 90, 60, 0.75); }
}
.stage.urgent .live { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.25); color: #fff; }
.stage.urgent .live i { background: #fff; animation-name: urgentLivePulse; }
@keyframes urgentLivePulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.5); }
  50% { opacity: 0.5; box-shadow: 0 0 0 9px rgba(255, 255, 255, 0); }
}

/* 公告样式：Notion 天蓝便签卡 */
.stage.notice .stage-bg {
  background:
    radial-gradient(80% 80% at 50% 45%, rgba(0, 117, 222, 0.12), transparent 62%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.65), rgba(238, 244, 252, 0.95));
}
.stage.notice .shout-text {
  background: #dcecfa;
  border-color: rgba(0, 117, 222, 0.28);
  box-shadow: rgba(15, 15, 15, 0.14) 0 16px 40px -8px;
  color: #0a2a52;
  text-shadow: none;
}
.stage.notice .live { background: rgba(0, 117, 222, 0.1); border-color: rgba(0, 117, 222, 0.28); color: #005bab; }

/* ====== 作业布置（homework）模式 ====== */
.stage.homework-mode .stage-bg {
  background:
    radial-gradient(70% 60% at 18% 20%, rgba(86, 69, 212, 0.1), transparent 65%),
    radial-gradient(60% 50% at 85% 80%, rgba(0, 117, 222, 0.08), transparent 70%),
    linear-gradient(180deg, #fafaf9 0%, #f0efed 100%);
}
.stage.homework-mode .stage-meta {
  color: #793400;
  font-weight: 600;
  letter-spacing: 2px;
  font-size: clamp(16px, 2.4vw, 28px);
  text-shadow: none;
}
/* 作业模式隐藏了顶部信息栏，收窄舞台留白，把省下的宽高让给作业模块 */
.stage.homework-mode {
  padding-top: clamp(16px, 2.5vh, 36px);
  padding-right: clamp(20px, 3vw, 64px);
  padding-bottom: clamp(14px, 2vh, 30px);
  padding-left: clamp(20px, 3vw, 64px);
}
/* 作业模式隐藏顶部信息栏（live 胶囊 + 来源 + meta）—— 卡片自己就是主体 */
.stage.homework-mode .stage-top { display: none !important; }
.stage.homework-mode .stage-bottom { display: none !important; }
.stage.homework-mode .stage-source {
  color: var(--muted);
  font-size: clamp(11px, 1.4vw, 14px);
}
.stage.homework-mode .text-wrap {
  display: flex;
  flex-direction: row;       /* 多卡片横排 */
  justify-content: center;
  align-items: stretch;
  height: auto;
}
.stage.homework-mode .text-wrap.hw-grid-wrap {
  /* 作业模块整体限制在大屏可视区域内，任何情况下都不溢出 */
  width: 100%;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  min-height: 0;
}
.stage.homework-mode .shout-text.hw-text {
  all: unset;
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: clamp(16px, 3vw, 32px) clamp(18px, 3.5vw, 40px);
  box-shadow: var(--shadow-card);
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
.stage.homework-mode .hw-item {
  display: flex;
  align-items: flex-start;
  gap: clamp(10px, 1.4vw, 18px);
  padding: clamp(8px, 1vw, 14px) 0;
  border-bottom: 1px dashed #ede9e4;
  color: #37352f;
  font-size: clamp(14px, 1.8vw, 22px);
  line-height: 1.7;
}
/* 作业条目字号必须跟随 fitCardContent 设置的卡片正文字号，
   否则行数多时字号不缩小，文字会被卡片裁掉 */
.stage.homework-mode .hw-card-body .hw-item { font-size: inherit; }
.stage.homework-mode .hw-item:last-child { border-bottom: none; }
.stage.homework-mode .hw-dot {
  flex: 0 0 auto;
  width: clamp(22px, 2.6vw, 36px);
  height: clamp(22px, 2.6vw, 36px);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(11px, 1.2vw, 15px);
  font-weight: 700;
  color: #0a1128;
  background: linear-gradient(135deg, #ffb547, #ff8a3a);
  box-shadow: 0 4px 14px rgba(255, 150, 70, 0.4);
  margin-top: clamp(2px, 0.2vw, 4px);
}
.stage.homework-mode .hw-line { flex: 1; }
.stage.homework-mode .live { background: rgba(221, 91, 0, 0.1); border-color: rgba(221, 91, 0, 0.3); color: #793400; }

/* 多老师作业并排（hw-grid-wrap） */
.text-wrap.hw-grid-wrap {
  display: flex;
  justify-content: center;
  align-items: stretch;
  flex-wrap: wrap;
  gap: clamp(10px, 1.2vw, 20px);
  max-width: 100%;
  width: 100%;
  height: 100%;
  padding: clamp(8px, 1vw, 16px);
  container-type: inline-size;
  /* banner + 卡片整组垂直居中，避免上面一片空白、下面空一片 */
  align-content: center;
}
/* 顶部 banner：今日作业（独占一整行，不参与卡片 wrap 计算） */
.hw-banner {
  flex: 0 0 100%;
  display: flex; align-items: baseline; gap: clamp(10px, 1.4vw, 18px);
  padding: clamp(6px, .8vw, 10px) clamp(4px, .5vw, 8px) clamp(12px, 1.6vw, 20px);
}
.hw-banner-title {
  font-size: clamp(22px, 3.6vw, 44px);
  font-weight: 700;
  background: linear-gradient(135deg, #3a2a99 0%, #5645d4 60%, #7b3ff2 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  letter-spacing: 2px;
  text-shadow: none;
}
.hw-banner-date {
  font-size: clamp(12px, 1.6vw, 18px);
  color: var(--muted);
  font-weight: 500;
}
.stage.hw-multi .text-wrap.hw-grid-wrap { gap: clamp(12px, 1.8vw, 28px); }
.hw-card {
  flex: 1 1 42%;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: clamp(10px, 1.4vw, 18px) clamp(12px, 1.8vw, 22px);
  box-shadow: rgba(15, 15, 15, 0.12) 0 12px 32px -8px;
  display: flex; flex-direction: column;
  animation: hwCardIn .38s cubic-bezier(.2,.9,.2,1);
  container-type: inline-size;
  container-name: hwcard;
  overflow: hidden;
  /* 卡片高度跟内容走，不再一律撑成大块 */
  min-height: clamp(110px, 15vh, 210px);
}
/* 只有一条作业时，卡片按文字量自然收放：短作业小而精致，长作业才铺开 */
.stage:not(.hw-multi) .hw-card {
  flex: 0 1 auto;
  width: fit-content;
  min-width: min(46vw, 680px);
  /* 上限定得比标准宽度宽，长行作业才能横向扩开而不是缩字 */
  max-width: min(88vw, 1280px);
  min-height: clamp(120px, 16vh, 230px);
  margin: 0 auto;
}
/* 多张作业：卡片宽度按内容收敛，文字少时不会撑成大片空框 */
.stage.hw-multi .hw-card {
  flex: 0 0 auto;
  width: fit-content;
  /* 最多用满所在列，不侵占相邻科目的位置 */
  max-width: min(47vw, 1100px);
}
@media (max-width: 900px) {
  .stage.hw-multi .hw-card { width: 100%; max-width: 100%; }
}
@keyframes hwCardIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.hw-card-head {
  display: flex; align-items: center; gap: 2cqw;
  flex-wrap: wrap;
  padding-bottom: 2.5cqw;
  margin-bottom: 2.5cqw;
  border-bottom: 1px solid #ede9e4;
  flex-shrink: 0;
}
.hw-subject-tag, .hw-grade-tag {
  font-size: clamp(13px, 3.6cqw, 20px);
  padding: 5px 14px; border-radius: 999px;
  font-weight: 700;
  letter-spacing: .04em;
}
.hw-subject-ic { margin-right: 6px; font-size: 1.05em; }
.hw-subject-tag {
  color: #fff;
}
/* 不同学科不同色系 */
.hw-subject-tag.s-语文   { background: linear-gradient(135deg, #e53935, #b71c1c); }
.hw-subject-tag.s-数学   { background: linear-gradient(135deg, #1e88e5, #0d47a1); }
.hw-subject-tag.s-英语   { background: linear-gradient(135deg, #43a047, #1b5e20); }
.hw-subject-tag.s-物理   { background: linear-gradient(135deg, #8e24aa, #4a148c); }
.hw-subject-tag.s-化学   { background: linear-gradient(135deg, #fb8c00, #e65100); }
.hw-subject-tag.s-生物   { background: linear-gradient(135deg, #00acc1, #006064); }
.hw-subject-tag.s-历史   { background: linear-gradient(135deg, #6d4c41, #3e2723); }
.hw-subject-tag.s-地理   { background: linear-gradient(135deg, #546e7a, #263238); }
.hw-subject-tag.s-政治   { background: linear-gradient(135deg, #d81b60, #880e4f); }
.hw-subject-tag.s-综合实践 { background: linear-gradient(135deg, #5c6bc0, #283593); }
.hw-subject-tag.s-default { background: linear-gradient(135deg, #7c4dff, #512da8); }
/* 卡片边框也跟随学科色系 */
.hw-card.c-语文   { border-color: rgba(229, 57, 53, 0.35); }
.hw-card.c-数学   { border-color: rgba(30, 136, 229, 0.35); }
.hw-card.c-英语   { border-color: rgba(67, 160, 71, 0.35); }
.hw-card.c-物理   { border-color: rgba(142, 36, 170, 0.35); }
.hw-card.c-化学   { border-color: rgba(251, 140, 0, 0.35); }
.hw-card.c-生物   { border-color: rgba(0, 172, 193, 0.35); }
.hw-card.c-历史   { border-color: rgba(109, 76, 65, 0.45); }
.hw-card.c-地理   { border-color: rgba(84, 110, 122, 0.45); }
.hw-card.c-政治   { border-color: rgba(216, 27, 96, 0.35); }
.hw-card.c-综合实践 { border-color: rgba(92, 107, 192, 0.35); }
.hw-targets-tag {
  background: #d9f3e1;
  border: 1px solid rgba(26, 174, 57, 0.32);
  color: #0f8f2e;
  font-size: clamp(10px, 2.8cqw, 14px);
}
.hw-from {
  margin-left: auto;
  font-size: clamp(10px, 2.6cqw, 13px);
  color: var(--muted);
  font-weight: 500;
}
.hw-close-in {
  margin-left: auto;
  font-size: clamp(10px, 2.6cqw, 15px);
  color: #793400;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.hw-from ~ .hw-close-in { margin-left: 0; }
.hw-x {
  width: 26px; height: 26px; border-radius: 50%;
  border: none; background: rgba(15, 15, 15, 0.05);
  color: #5d5b54; font-size: 16px; font-weight: 700;
  line-height: 1; cursor: pointer;
  transition: all .18s;
  flex-shrink: 0;
}
.hw-x:hover { background: rgba(224, 49, 49, 0.12); color: #b02a2a; }
.hw-card-body {
  display: flex; flex-direction: column; gap: 1.2cqw;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  /* 内容垂直居中；内容超出时从顶部开始，避免上下同时被裁 */
  justify-content: safe center;
  font-size: clamp(15px, 3.8cqw, 26px);
}
.hw-card-body .hw-item {
  display: flex; align-items: flex-start;
  /* 不允许条目被压缩：高度不足时由 fitCardContent 缩字号，而不是裁掉文字 */
  flex: 0 0 auto;
  gap: 2.2cqw;
  padding: 1.6cqw 0;
  border-bottom: 1px dashed #ede9e4;
  color: #37352f;
  /* 实际字号由 fitCardContent 按文字量算，这里只继承 */
  font-size: inherit;
  line-height: 1.8;
  font-weight: 500;
}
.hw-card-body .hw-item:last-child { border-bottom: none; }
.stage.notice .live i { background: var(--blue); }

/* 滚动字幕 */
.stage.scroll-mode .text-wrap { justify-content: flex-start; align-items: center; }
.stage.scroll-mode .shout-text {
  white-space: nowrap;
  max-width: none;
  max-height: none;
  text-align: left;
  animation: none;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  border-radius: 0;
  font-size: clamp(36px, 10vh, 120px);
  line-height: 1.2;
  color: var(--text);
  text-shadow: none;
  will-change: transform;
}

/* 弹窗样式：Notion 高亮黄横幅 */
.stage.popup .stage-bg {
  background:
    radial-gradient(120% 100% at 50% 50%, rgba(86, 69, 212, 0.08), rgba(246, 245, 244, 0.95));
}
.stage.popup .shout-text {
  background: #f9e79f;
  border: 2px solid rgba(221, 91, 0, 0.35);
  box-shadow: rgba(15, 15, 15, 0.14) 0 16px 40px -8px;
  color: #37352f;
  text-shadow: none;
}
.stage.popup .live {
  background: rgba(221, 91, 0, 0.1);
  border-color: rgba(221, 91, 0, 0.32);
  color: #793400;
}
.stage.popup .live i { background: #dd5b00; }

/* ---------- 语音喊话卡片 ---------- */

.voice-card {
  position: absolute;
  left: 50%;
  bottom: clamp(90px, 15vh, 180px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: clamp(14px, 1.6vw, 22px);
  padding: clamp(14px, 1.8vh, 22px) clamp(20px, 2.4vw, 34px);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  max-width: min(760px, 88vw);
  animation: cardIn 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  z-index: 9;
}
@keyframes cardIn {
  from { opacity: 0; transform: translate(-50%, 24px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.voice-icon {
  width: clamp(44px, 5vh, 58px);
  height: clamp(44px, 5vh, 58px);
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--purple);
  background: rgba(86, 69, 212, 0.08);
  border: 1px solid rgba(86, 69, 212, 0.25);
}
.voice-icon svg { width: 55%; height: 55%; stroke-width: 1.8; }
.voice-body { min-width: 0; }
.voice-title {
  font-size: clamp(16px, 1.7vw, 24px);
  font-weight: 600;
  letter-spacing: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46vw;
}
.voice-sub { font-size: clamp(10px, 0.9vw, 12px); color: var(--muted); letter-spacing: 2px; margin-top: 3px; }
.eq { display: flex; align-items: center; gap: 4px; height: 30px; margin-left: auto; flex: none; }
.eq i {
  width: 3px;
  height: 8px;
  border-radius: 3px;
  background: linear-gradient(180deg, #7b3ff2, #5645d4);
  animation: eqBar 0.9s ease-in-out infinite;
}
.eq i:nth-child(1) { animation-delay: 0.05s; }
.eq i:nth-child(2) { animation-delay: 0.28s; }
.eq i:nth-child(3) { animation-delay: 0.12s; }
.eq i:nth-child(4) { animation-delay: 0.4s; }
.eq i:nth-child(5) { animation-delay: 0.2s; }
.eq i:nth-child(6) { animation-delay: 0.33s; }
.eq i:nth-child(7) { animation-delay: 0.08s; }
@keyframes eqBar {
  0%, 100% { height: 7px; opacity: 0.55; }
  50% { height: 28px; opacity: 1; }
}

/* ---------- 进度 ---------- */

.stage-bottom {
  position: absolute;
  left: clamp(24px, 6vw, 130px);
  right: clamp(24px, 6vw, 130px);
  bottom: clamp(30px, 5vh, 54px);
  z-index: 6;
}
.progress {
  height: 3px;
  border-radius: 4px;
  background: rgba(15, 15, 15, 0.08);
  overflow: hidden;
}
.progress i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: var(--purple);
  transition: width 0.5s linear;
}
.stage-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  font-size: clamp(10px, 0.8vw, 12px);
  color: #a4a097;
  letter-spacing: 1px;
}

/* ---------- 确认收到 ---------- */

.stage.ack-mode .progress { opacity: 0; }
/* 有确认按钮时，文字区域只占确认层上方，避免按钮/提示遮挡播报文字 */
.stage.ack-mode .text-wrap {
  position: absolute;
  left: clamp(24px, 6vw, 130px);
  right: clamp(24px, 6vw, 130px);
  top: clamp(80px, 11vh, 130px);
  bottom: calc(clamp(48px, 6vh, 78px) + 110px);
  width: auto;
  height: auto;
}

.ack-layer {
  position: absolute;
  left: 50%;
  bottom: clamp(48px, 6vh, 78px);
  transform: translateX(-50%);
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: clamp(9px, 1.1vh, 14px) clamp(12px, 1.4vw, 20px);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  box-shadow: rgba(15, 15, 15, 0.14) 0 16px 40px -8px;
  animation: ackRise 0.45s ease both;
}
@keyframes ackRise { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }

.ack-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: clamp(150px, 15vw, 230px);
  height: clamp(42px, 5vh, 60px);
  padding: 0 clamp(16px, 2vw, 28px);
  border-radius: 10px;
  border: 1px solid rgba(15, 15, 15, 0.08);
  background: #1aae39;
  color: #fff;
  font-size: clamp(13px, 1.4vw, 18px);
  font-weight: 700;
  letter-spacing: 2px;
  box-shadow: 0 4px 12px rgba(15, 15, 15, 0.1);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.2s ease, opacity 0.2s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.ack-btn svg { width: clamp(16px, 1.5vw, 22px); height: clamp(16px, 1.5vw, 22px); stroke-width: 2.2; }
.ack-btn:hover { background: #0f8f2e; transform: translateY(-1px); box-shadow: 0 10px 26px rgba(26, 174, 57, 0.3); }
.ack-btn:active { transform: translateY(1px) scale(0.985); }
.ack-btn:disabled { cursor: default; opacity: 0.55; }
.ack-btn.confirmed {
  background: #0075de;
  box-shadow: 0 4px 12px rgba(15, 15, 15, 0.1);
}

.ack-countdown {
  margin-top: 2px;
  font-size: clamp(11px, 1.1vw, 13px);
  color: #793400;
  letter-spacing: 1px;
  font-weight: 500;
  white-space: nowrap;
}
.ack-countdown.hidden { display: none !important; }

@media (max-width: 760px) {
  .ack-layer { bottom: 78px; width: calc(100% - 40px); padding: 10px; }
  .stage.ack-mode .text-wrap { top: 124px; bottom: calc(78px + 108px); }
  .ack-btn { width: auto; max-width: 320px; margin: 0 auto; height: 50px; font-size: 16px; letter-spacing: 3px; border-radius: 999px; padding: 0 24px; }
}

/* ---------- 浮层 ---------- */

.toast-layer {
  position: absolute;
  top: clamp(70px, 9vh, 110px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
.toast {
  padding: 10px 22px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--line);
  color: #37352f;
  font-size: clamp(12px, 1vw, 14px);
  letter-spacing: 1px;
  box-shadow: rgba(15, 15, 15, 0.14) 0 16px 40px -8px;
  animation: toastIn 0.3s ease;
}
.toast.ok { border-color: rgba(26, 174, 57, 0.4); color: #0f8f2e; }
.toast.err { border-color: rgba(224, 49, 49, 0.4); color: #b02a2a; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

.unbound-mask {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(246, 245, 244, 0.96);
  text-align: center;
  padding: 24px;
}
.unbound-title { font-size: clamp(20px, 2.4vw, 30px); font-weight: 600; letter-spacing: 2px; margin-bottom: 10px; }
.unbound-sub { font-size: 13px; color: var(--muted); letter-spacing: 1px; }

/* ---------- 响应式 ---------- */

@media (max-aspect-ratio: 1/1) {
  .hud { padding: 14px 18px; }
  .hud-name { font-size: 14px; }
  .hud-tag { display: none; }
  .stage { padding: 100px 20px 80px; }
  .stage-top { top: 84px; left: 20px; right: 20px; }
  .stage-bottom { left: 20px; right: 20px; bottom: 24px; }
  .pair-code { letter-spacing: 8px; }
  .voice-card { bottom: 110px; padding: 12px 16px; }
  .voice-title { max-width: 48vw; font-size: 16px; }
  .eq { display: none; }
  .idle-device { margin-top: 28px; font-size: 13px; }
}

@media (max-width: 720px) {
  .hud-status span#connText { display: none; }
  .pair-card { padding: 30px 20px; }
  .pair-code { font-size: 58px; letter-spacing: 8px; }
  .pair-desc { font-size: 13px; }
  .pair-server { font-size: 10px; }
  .stage.urgent::after { border-width: 6px; }
}

@media (max-height: 500px) {
  .stage-top { top: 48px; }
  .stage { padding: 70px 30px 60px; }
  .stage-bottom { bottom: 16px; }
}

/* 屏幕高度有限时（如 1366×768）压缩 banner 与卡片头部，把高度让给作业正文 */
@media (max-height: 820px) {
  .stage.homework-mode .hw-banner { padding: 2px 4px 8px; }
  .stage.homework-mode .hw-banner-title { font-size: clamp(18px, 4vh, 30px); }
  .stage.homework-mode .hw-banner-date { display: none; }
  .stage.hw-multi .hw-card { padding: 12px 14px; }
  .stage.hw-multi .hw-card-head { padding-bottom: 1.2cqw; margin-bottom: 1.2cqw; }
}

body.idle-cursor { cursor: none; }

