:root {
  --bg: #eef2f8;
  --card: #ffffff;
  --text: #16233b;
  --muted: #6c7a91;
  --line: #e4eaf3;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-soft: #e8effd;
  --green: #0ea472;
  --green-soft: #e5f7f0;
  --amber: #f59e0b;
  --red: #e5484d;
  --shadow: 0 1px 2px rgba(22, 35, 59, 0.04), 0 8px 24px rgba(22, 35, 59, 0.07);
  --radius: 18px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
}

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 18px calc(28px + env(safe-area-inset-bottom));
}

/* ---------- 顶部标题 ---------- */
.top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 2px 18px;
}

.top .logo {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(145deg, #3b82f6, #2563eb);
  display: grid;
  place-items: center;
  color: #fff;
  flex: none;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
}

.top h1 {
  font-size: 18px;
  font-weight: 650;
  margin: 0;
  letter-spacing: 0.2px;
}

.top .sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 1px;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card h2 {
  font-size: 15px;
  font-weight: 650;
  margin: 0 0 4px;
}

.card .hint {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 14px;
}

/* ---------- 首页门户 ---------- */
.hero {
  padding: 34px 4px 26px;
  text-align: center;
}

.hero h1 {
  font-size: 25px;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: 0.3px;
}

.hero p {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

.portal {
  display: grid;
  gap: 14px;
}

.portal a {
  display: block;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 20px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  border: 1px solid transparent;
}

.portal a:active {
  transform: scale(0.985);
  box-shadow: 0 2px 8px rgba(22, 35, 59, 0.08);
}

.portal .row {
  display: flex;
  align-items: center;
  gap: 15px;
}

.portal .ico {
  width: 50px;
  height: 50px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  flex: none;
}

.portal .ico.blue {
  background: var(--brand-soft);
  color: var(--brand);
}

.portal .ico.green {
  background: var(--green-soft);
  color: var(--green);
}

.portal .t {
  font-size: 16.5px;
  font-weight: 650;
}

.portal .d {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.portal .chev {
  margin-left: auto;
  color: #c3ccd9;
}

.footnote {
  text-align: center;
  font-size: 12px;
  color: #98a4b6;
  padding: 18px 10px 4px;
  line-height: 1.7;
}

/* ---------- 表单 ---------- */
label.field {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
select {
  width: 100%;
  padding: 13px 14px;
  font-size: 16px;
  color: var(--text);
  background: #f7f9fc;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  outline: none;
  appearance: none;
  transition: border-color 0.15s, background 0.15s;
}

input:focus,
select:focus {
  border-color: var(--brand);
  background: #fff;
}

/* ---------- 教室多选 ---------- */
.rooms {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.room-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 12px 12px;
  border-radius: 13px;
  background: #f7f9fc;
  border: 1.5px solid var(--line);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.room-chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  flex: none;
  transition: background 0.15s;
}

.room-chip .nm {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-chip .cnt {
  margin-left: auto;
  font-size: 11.5px;
  color: #9aa7b9;
  flex: none;
}

.room-chip.on {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-dark);
  font-weight: 600;
}

.room-chip.on .dot {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(14, 164, 114, 0.16);
}

.room-chip.on .cnt {
  color: var(--brand);
}

/* ---------- 按钮 ---------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px 18px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  background: #f1f4f9;
  color: var(--text);
  transition: transform 0.12s, filter 0.15s, background 0.15s;
}

.btn:active {
  transform: scale(0.985);
}

.btn.primary {
  background: linear-gradient(160deg, #3b82f6, #2563eb);
  color: #fff;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.28);
}

.btn.primary:disabled {
  background: #c7d3e6;
  box-shadow: none;
  color: #fff;
}

.btn.ghost {
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--muted);
  font-weight: 500;
  font-size: 14.5px;
  padding: 12px;
}

.btn.danger {
  background: #fdeced;
  color: var(--red);
}

/* ---------- 状态条 ---------- */
.status {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  padding: 11px 14px;
  border-radius: 12px;
  background: #f7f9fc;
  color: var(--muted);
  margin-bottom: 14px;
}

.status .led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  flex: none;
}

.status.ok {
  background: var(--green-soft);
  color: #0a7a56;
}

.status.ok .led {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(14, 164, 114, 0.18);
}

.status.warn {
  background: #fef4e6;
  color: #a86508;
}

.status.warn .led {
  background: var(--amber);
}

.status.bad {
  background: #fdeced;
  color: #b3272c;
}

.status.bad .led {
  background: var(--red);
}

.status .spacer {
  margin-left: auto;
}

/* ---------- PTT 大按钮 ---------- */
.talk-zone {
  display: grid;
  place-items: center;
  padding: 12px 0 6px;
}

.talk {
  position: relative;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: linear-gradient(160deg, #4b8cf7, #2563eb);
  color: #fff;
  display: grid;
  place-items: center;
  gap: 4px;
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.32), inset 0 -3px 0 rgba(0, 0, 0, 0.08);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  transition: transform 0.1s ease, box-shadow 0.12s ease;
}

.talk .big {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 1px;
}

.talk .small {
  font-size: 12px;
  opacity: 0.78;
}

.talk.on {
  transform: scale(0.96);
  background: linear-gradient(160deg, #f26d72, #e5484d);
  box-shadow: 0 6px 24px rgba(229, 72, 77, 0.4), 0 0 0 12px rgba(229, 72, 77, 0.1);
}

.talk:disabled {
  background: #c9d4e6;
  box-shadow: none;
  color: #fff;
}

/* 音量环 */
.meter {
  height: 6px;
  border-radius: 99px;
  background: #e9eef6;
  overflow: hidden;
  margin: 16px 0 0;
}

.meter i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, #34d399, #10b981);
  transition: width 0.08s linear;
}

.meter.hot i {
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
}

/* ---------- 开关 ---------- */
.switch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 2px;
}

.switch-row .txt {
  flex: 1;
}

.switch-row .t {
  font-size: 14.5px;
  font-weight: 550;
}

.switch-row .d {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

.sw {
  position: relative;
  width: 50px;
  height: 30px;
  border-radius: 99px;
  background: #d7dfeb;
  flex: none;
  transition: background 0.18s;
  cursor: pointer;
}

.sw::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  transition: transform 0.18s ease;
}

.sw.on {
  background: var(--brand);
}

.sw.on::after {
  transform: translateX(20px);
}

/* ---------- 接收端 ---------- */
body.recv {
  background: #0e1526;
  color: #e8eef8;
}

body.recv .wrap {
  max-width: 900px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 26px 26px calc(26px + env(safe-area-inset-bottom));
}

.recv-head {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #93a3bd;
  font-size: 15px;
}

.recv-head .room {
  font-size: 26px;
  font-weight: 700;
  color: #f2f6fc;
  letter-spacing: 0.5px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: 99px;
  font-size: 12.5px;
  background: rgba(255, 255, 255, 0.07);
  color: #a9b8cf;
}

.pill .led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #64748b;
}

.pill.ok {
  background: rgba(16, 185, 129, 0.14);
  color: #6ee7b7;
}

.pill.ok .led {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}

.pill.bad {
  background: rgba(229, 72, 77, 0.15);
  color: #fda4a7;
}

.pill.bad .led {
  background: #e5484d;
}

.recv-main {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 30px 0;
  text-align: center;
}

.wave {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  height: 120px;
  margin-bottom: 34px;
}

.wave span {
  width: 11px;
  border-radius: 99px;
  background: #26344d;
  height: 12px;
  transition: height 0.1s linear, background 0.25s;
}

body.live .wave span {
  background: linear-gradient(180deg, #34d399, #059669);
}

.recv-title {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #eef3fb;
  margin: 0 0 10px;
}

.recv-sub {
  font-size: 15px;
  color: #8b9bb5;
  margin: 0;
  min-height: 22px;
}

.recv-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: #5f6f89;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.recv-foot .mini {
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #a9b8cf;
  font-size: 12.5px;
}

/* 接收端入场遮罩 */
.unlock {
  position: fixed;
  inset: 0;
  background: radial-gradient(120% 90% at 50% 0%, #1b2740 0%, #0b1220 70%);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 20;
  text-align: center;
}

.unlock.hide {
  display: none;
}

.unlock .inner {
  max-width: 420px;
  width: 100%;
}

.unlock h2 {
  font-size: 22px;
  margin: 0 0 10px;
  color: #f0f5fc;
}

.unlock p {
  color: #8b9bb5;
  font-size: 14px;
  margin: 0 0 26px;
  line-height: 1.7;
}

.unlock .btn.primary {
  padding: 17px;
  font-size: 17px;
}

.unlock .btn {
  background: rgba(255, 255, 255, 0.08);
  color: #cfdaea;
}

.unlock .btn.primary {
  background: linear-gradient(160deg, #3b82f6, #2563eb);
  color: #fff;
  box-shadow: 0 8px 26px rgba(37, 99, 235, 0.38);
}

.unlock select {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: #edf3fc;
  text-align: center;
  margin-bottom: 14px;
}

.unlock select option {
  color: #16233b;
}

.unlock .err {
  color: #fda4a7;
  font-size: 13px;
  margin-top: 12px;
  min-height: 18px;
}

/* ---------- 提示浮层 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: rgba(22, 35, 59, 0.94);
  color: #fff;
  font-size: 13.5px;
  padding: 11px 18px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.22s ease;
  z-index: 50;
  max-width: 86vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.hidden {
  display: none !important;
}

@media (max-width: 380px) {
  .rooms {
    grid-template-columns: 1fr;
  }
  .talk {
    width: 168px;
    height: 168px;
  }
}
