:root {
  --bg: #f4f7f9;
  --card: #ffffff;
  --ink: #14313d;
  --muted: #607680;
  --brand: #0aa5a5;
  --brand-dark: #087f80;
  --danger: #d64545;
  --line: #d9e3e7;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; }

.hidden { display: none !important; }

/* ---------- 登录面板 ---------- */
#login {
  max-width: 520px;
  margin: 8vh auto;
  padding: 28px;
  background: var(--card);
  border-radius: 20px;
  box-shadow: 0 8px 30px rgba(20, 49, 61, .08);
}

#login h1 {
  margin: 0 0 6px;
  font-size: 30px;
  text-align: center;
}

#login .sub {
  margin: 0 0 24px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}

label {
  display: block;
  font-size: 16px;
  margin: 14px 0 6px;
  font-weight: 600;
}

input {
  width: 100%;
  padding: 14px 16px;
  font-size: 18px;
  border: 2px solid var(--line);
  border-radius: 12px;
  outline: none;
}

input:focus { border-color: var(--brand); }

button.primary, button.danger, .mode {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 16px;
  font-size: 19px;
  font-weight: 700;
  color: #fff;
  background: var(--brand);
  margin-top: 22px;
  cursor: pointer;
}

button.primary:active, .mode:active { background: var(--brand-dark); }

button.danger {
  background: var(--danger);
  width: auto;
  margin: 0;
  padding: 10px 20px;
  font-size: 16px;
}

#loginMsg { color: var(--danger); min-height: 24px; font-size: 15px; }

/* ---------- 主界面 ---------- */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 12px;
}

header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px 12px;
  font-size: 17px;
}

#statusDot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #c7d2d6;
  flex: none;
}

#statusDot.on { background: #29b473; }
#statusDot.warn { background: #e2a23a; }
#statusText { flex: 1; font-weight: 600; }

/* 静音按钮 */
.icon-btn {
  flex: none;
  width: 42px;
  height: 42px;
  padding: 9px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--brand-dark);
  cursor: pointer;
}
.icon-btn svg { width: 100%; height: 100%; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.muted { background: var(--danger); border-color: var(--danger); color: #fff; }
.icon-btn .mute-x { display: none; }
.icon-btn.muted .wave { display: none; }
.icon-btn.muted .mute-x { display: block; }

/* 音量滑块 */
.vol-control {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 4px 0;
}
.vol-label { font-size: 15px; color: var(--muted); flex: none; font-weight: 600; }
#volumeSlider {
  flex: 1;
  width: auto;
  padding: 0;
  border: none;
  height: 28px;
  accent-color: var(--brand);
  cursor: pointer;
}
#volumeValue { min-width: 46px; text-align: right; font-size: 14px; color: var(--brand-dark); font-weight: 700; }

.stage {
  position: relative;
  flex: 1;
  min-height: 260px;
  background: #0d1b21;
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#remoteCanvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #0d1b21;
}

.placeholder {
  position: absolute;
  color: #9fb6bd;
  font-size: 18px;
  text-align: center;
  padding: 20px;
  pointer-events: none;
}

.pip {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 132px;
  height: 99px;
  object-fit: contain; /* 等比显示，防止画中画被拉伸变形 */
  border: 2px solid rgba(255, 255, 255, .75);
  border-radius: 10px;
  background: #16282f;
}

#localVideo { display: none; }

.modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.mode {
  margin: 0;
  padding: 14px 6px;
  font-size: 17px;
  background: var(--card);
  color: var(--brand-dark);
  border: 2px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.mode svg { width: 30px; height: 30px; stroke: currentColor; fill: none; stroke-width: 2; }
.mode.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.hint {
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  margin: 10px 0 2px;
}

/* ---------- 老人端全屏 ---------- */
body.elder { background: #000; overflow: hidden; }
body.elder #elderStage { position: fixed; inset: 0; }
/* object-fit:contain 等比缩放显示，画面比例与窗口不符时留黑边而不是拉伸变形 */
body.elder #familyCanvas { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
body.elder #elderVideo { position: fixed; left: 0; top: 0; width: 1px; height: 1px; opacity: 0.01; pointer-events: none; z-index: -1; }
body.elder #elderStatus {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px;
  text-align: center;
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(transparent, rgba(0, 0, 0, .75));
  pointer-events: none;
}
body.elder #elderError {
  position: fixed;
  inset: auto 16px 90px;
  padding: 18px;
  border-radius: 14px;
  background: #fff5f5;
  color: #a12c2c;
  font-size: 19px;
  line-height: 1.5;
  text-align: center;
  display: none;
}
