/* 教室电脑 · 接收端 */
body.receiver {
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(1100px 620px at 12% -10%, #fff3dd 0%, rgba(255, 243, 221, 0) 60%),
    radial-gradient(900px 520px at 100% 0%, #ffe9d5 0%, rgba(255, 233, 213, 0) 55%),
    var(--cream);
}

.screen { height: 100%; display: grid; grid-template-rows: auto 1fr auto; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2.0vh 2.4vw; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; flex: 0 0 auto;
  background: linear-gradient(140deg, #ffb457, #f4761a);
  box-shadow: 0 10px 20px rgba(244, 118, 26, .28);
}
.logo svg { width: 28px; height: 28px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.class-name {
  font-size: clamp(20px, 2.1vh, 30px); font-weight: 800; letter-spacing: .5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 34vw;
}
.brand-sub { font-size: clamp(11px, 1.25vh, 14px); color: var(--muted); letter-spacing: 1.6px; margin-top: 2px; }

.top-right { display: flex; align-items: center; gap: 18px; }

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, .78); border: 1px solid var(--line);
  padding: 8px 16px; border-radius: 999px; font-size: clamp(12px, 1.4vh, 15px);
  color: var(--muted); font-weight: 600; backdrop-filter: blur(8px);
}
.pill b { color: var(--ink); letter-spacing: 2px; font-size: 1.05em; }
.pill .status-text { min-width: 3.4em; }

.clock { text-align: right; line-height: 1.1; }
.clock b { display: block; font-size: clamp(24px, 3.2vh, 42px); font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.clock span { font-size: clamp(11px, 1.25vh, 14px); color: var(--muted); }

.icon-btn {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: rgba(255, 255, 255, .78); border: 1px solid var(--line); color: var(--muted);
  transition: all .16s ease;
}
.icon-btn:hover { color: var(--ink); background: #fff; transform: translateY(-1px); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.on { color: #fff; background: linear-gradient(140deg, #fb8c2e, #ef6a10); border-color: transparent; }

/* ---------- 主区域 ---------- */
.stage { position: relative; padding: 0 2.4vw; min-height: 0; }
.view { position: absolute; inset: 0 2.4vw; display: flex; }

/* 待机 */
.idle { align-items: center; justify-content: center; flex-direction: column; gap: 2.6vh; }
.idle-card {
  display: flex; align-items: center; gap: 3.4vw;
  background: rgba(255, 255, 255, .72); border: 1px solid #f3e6d4;
  border-radius: 36px; padding: 5vh 3.6vw; box-shadow: var(--shadow);
  backdrop-filter: blur(6px); width: min(1380px, 90vw);
}
.horn-wrap { position: relative; flex: 0 0 auto; display: grid; place-items: center; }
.horn { width: clamp(140px, 23vh, 280px); height: clamp(140px, 23vh, 280px); }
.horn .wave { animation: waveOut 2.6s ease-out infinite; transform-origin: 72% 50%; }
.horn .wave:nth-child(2) { animation-delay: .45s; }
.horn .wave:nth-child(3) { animation-delay: .9s; }
@keyframes waveOut { 0% { opacity: 0; transform: scale(.82); } 25% { opacity: .85; } 100% { opacity: 0; transform: scale(1.18); } }

.idle-copy { flex: 1; min-width: 0; }
.idle-copy h1 {
  margin: 0 0 1.6vh; font-size: clamp(28px, 4.4vh, 56px); letter-spacing: 1px;
}
.idle-copy p { margin: 0; color: var(--muted); font-size: clamp(14px, 1.95vh, 21px); line-height: 1.75; max-width: 24em; }
.idle-tips { margin-top: 2.4vh; display: flex; flex-wrap: wrap; gap: 10px; }
.tag {
  font-size: clamp(12px, 1.5vh, 16px); color: #9a6a2a; background: var(--orange-soft);
  border: 1px solid #ffe0bd; padding: 8px 16px; border-radius: 999px; font-weight: 600;
}

.qr-block {
  flex: 0 0 auto; text-align: center; background: #fff; border-radius: 28px;
  padding: 20px 20px 18px; box-shadow: var(--shadow-sm); border: 1px solid #f3e6d4;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.qr-box { width: clamp(150px, 22vh, 250px); height: clamp(150px, 22vh, 250px); }
.qr-cap { font-size: clamp(11px, 1.35vh, 14px); color: var(--muted); letter-spacing: .5px; }
.code-big { font-size: clamp(18px, 2.4vh, 28px); font-weight: 800; letter-spacing: 5px; color: var(--orange); }

/* 消息展示 */
.msg { flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 0 2vw; }
.msg-meta {
  display: flex; align-items: center; gap: 12px; margin-bottom: 3vh;
  font-size: clamp(13px, 1.5vh, 17px); color: var(--muted); font-weight: 600;
}
.msg-meta .from {
  color: var(--orange); background: var(--orange-soft); border: 1px solid #ffe0bd;
  padding: 7px 16px; border-radius: 999px; font-size: 1em; letter-spacing: .5px;
}
.msg-meta .lvl {
  color: #fff; background: var(--red); padding: 7px 16px; border-radius: 999px; letter-spacing: 1px;
}
.msg-text {
  font-weight: 800; line-height: 1.34; letter-spacing: 1px; white-space: pre-wrap; word-break: break-word;
  text-wrap: balance;
  max-width: 92%; color: var(--ink);
}
.msg.enter .msg-text, .msg.enter .msg-meta { animation: popIn .5s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes popIn { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }

.speaking {
  margin-top: 3.4vh; display: inline-flex; align-items: center; gap: 12px;
  color: var(--orange); font-weight: 700; font-size: clamp(13px, 1.5vh, 17px); letter-spacing: 1px;
  opacity: 0; transition: opacity .25s ease;
}
.speaking.on { opacity: 1; }
.bars { display: inline-flex; align-items: flex-end; gap: 4px; height: 20px; }
.bars i { width: 5px; border-radius: 3px; background: currentColor; height: 40%; animation: bar .9s ease-in-out infinite; }
.bars i:nth-child(2) { animation-delay: .15s; }
.bars i:nth-child(3) { animation-delay: .3s; }
.bars i:nth-child(4) { animation-delay: .45s; }
.bars i:nth-child(5) { animation-delay: .6s; }
@keyframes bar { 0%, 100% { height: 26%; } 50% { height: 100%; } }

/* 紧急消息整体换色 */
body.urgent { background: linear-gradient(150deg, #fff5f5 0%, #ffe8e8 100%); }
body.urgent .msg-text { color: #b3123c; }
body.urgent .speaking { color: var(--red); }

/* ---------- 底部历史 ---------- */
.footbar {
  display: flex; align-items: center; gap: 14px; padding: 1.4vh 2.4vw 2.0vh;
  min-height: 0;
}
.hist-label { font-size: clamp(11px, 1.3vh, 13px); color: #a79a86; letter-spacing: 1.6px; flex: 0 0 auto; }
.hist-list { display: flex; gap: 10px; overflow: hidden; flex: 1; }
.hist-item {
  display: flex; align-items: center; gap: 10px; background: rgba(255, 255, 255, .8);
  border: 1px solid var(--line); border-radius: 14px; padding: 10px 15px;
  font-size: clamp(12px, 1.5vh, 16px); color: #4a5563; max-width: 28vw; flex: 0 0 auto;
  animation: fadeUp .35s ease both; cursor: pointer;
}
.hist-item:hover { background: #fff; border-color: #ffd9b0; }
.hist-item .t { color: #ad9f8c; font-variant-numeric: tabular-nums; }
.hist-item .x { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 开始遮罩 ---------- */
.start-mask {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(255, 248, 238, .82); backdrop-filter: blur(10px); text-align: center;
}
.start-mask .inner { display: grid; place-items: center; gap: 18px; }
.start-mask h2 { margin: 0; font-size: clamp(22px, 3vh, 34px); }
.start-mask p { margin: 0; color: var(--muted); font-size: clamp(13px, 1.5vh, 16px); line-height: 1.7; max-width: 36ch; }
.start-btn {
  margin-top: 8px; padding: 20px 54px; border-radius: 999px; font-size: clamp(18px, 2.2vh, 24px); font-weight: 800;
  color: #fff; background: linear-gradient(135deg, #fb8c2e, #ef6a10);
  box-shadow: 0 18px 36px rgba(242, 102, 12, .32); letter-spacing: 1px;
  animation: pulseBtn 2.4s ease-in-out infinite;
}
@keyframes pulseBtn { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.035); } }

/* ---------- 设置抽屉 ---------- */
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(420px, 92vw); z-index: 70;
  background: #fff; box-shadow: -24px 0 60px rgba(60, 40, 10, .16);
  transform: translateX(105%); transition: transform .3s cubic-bezier(.3, .9, .3, 1);
  display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 22px; border-bottom: 1px solid #f2ece2;
}
.drawer-head h3 { margin: 0; font-size: 17px; }
.drawer-body { padding: 8px 22px 24px; overflow-y: auto; }
.field { padding: 16px 0; border-bottom: 1px dashed #f0e9df; }
.field:last-child { border-bottom: 0; }
.field label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 9px; letter-spacing: .3px; }
.field .row { display: flex; align-items: center; gap: 10px; }
.text-in, .select-in {
  width: 100%; padding: 11px 14px; border-radius: 12px; border: 1.5px solid var(--line);
  background: #fffdfa; outline: none; transition: border .16s ease; font-size: 15px;
}
.text-in:focus, .select-in:focus { border-color: var(--amber); background: #fff; }
.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row input[type=range] { flex: 1; accent-color: var(--orange); }
.slider-row b { width: 44px; text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; }

.seg { display: flex; gap: 6px; background: #f7f1e8; padding: 5px; border-radius: 12px; }
.seg button { flex: 1; padding: 9px 4px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch .sw { width: 48px; height: 28px; border-radius: 999px; background: #e3d9cb; position: relative; transition: background .2s ease; flex: 0 0 auto; }
.switch .sw::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .18); transition: transform .2s ease;
}
.switch.on .sw { background: var(--green); }
.switch.on .sw::after { transform: translateX(20px); }
.switch-label { font-size: 15px; font-weight: 600; }

.hint { font-size: 12px; color: #9a8f80; line-height: 1.65; margin-top: 8px; }

/* 遮罩 */
.scrim { position: fixed; inset: 0; background: rgba(30, 20, 10, .28); opacity: 0; pointer-events: none; transition: opacity .25s ease; z-index: 65; }
.scrim.on { opacity: 1; pointer-events: auto; }

/* 紧急消息的边缘提醒 */
body.urgent::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 5;
  box-shadow: inset 0 0 0 7px rgba(225, 29, 72, .38);
  animation: urgentPulse 1.9s ease-in-out infinite;
}
@keyframes urgentPulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

.net-warn {
  margin-top: 2vh; padding: 12px 18px; border-radius: 14px; font-size: clamp(12px, 1.4vh, 15px);
  color: #a3231f; background: #ffeeed; border: 1px solid #ffd2ce; line-height: 1.6; max-width: 26em;
}
