:root {
  --bg: #0b1020;
  --card: #161c30;
  --accent: #4f7cff;
  --danger: #ff4f5e;
  --success: #2ec27e;
  --text: #eef1f8;
  --muted: #8a92ad;
}

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

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

.screen {
  min-height: 100%;
  padding: max(env(safe-area-inset-top), 16px) 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hidden {
  display: none !important;
}

#setup-screen {
  justify-content: center;
  align-items: center;
}

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

h1 {
  margin: 0 0 4px;
  font-size: 28px;
  text-align: center;
}

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

.hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 12px;
}

input[type="text"] {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #2a3252;
  background: #0e1428;
  color: var(--text);
  font-size: 16px;
  margin-bottom: 12px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 12px;
}

.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
}
.btn.danger {
  background: var(--danger);
}
.btn.success {
  background: var(--success);
}
.btn.link {
  background: none;
  color: var(--muted);
  max-width: 420px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
  font-size: 14px;
  color: var(--muted);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.dot.on {
  background: var(--success);
}
.dot.off {
  background: var(--danger);
}

.contacts {
  list-style: none;
  margin: 0;
  padding: 0;
}
.contacts li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #232a45;
}
.contacts li:last-child {
  border-bottom: none;
}
.contact-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.contacts .dot {
  width: 10px;
  height: 10px;
  flex: none;
}
.contacts .dot.on {
  background: var(--success);
}
.contacts .dot.off {
  background: #6b7280; /* 离线显示灰色 */
}
.contacts button {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
}

/* 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 50;
}
.modal-card {
  background: var(--card);
  border-radius: 20px;
  padding: 32px 24px;
  text-align: center;
  width: 86%;
  max-width: 360px;
}
.modal-card h2 {
  margin: 8px 0;
  word-break: break-all;
}
.avatar {
  font-size: 56px;
  margin-bottom: 8px;
}
.avatar.pulse {
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.15);
  }
}
.row {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}
.row .btn {
  flex: 1;
}

/* 通话界面 */
#call-screen {
  padding: 0;
  position: fixed;
  inset: 0;
  background: #000;
}
.remote-video {
  position: absolute;
  inset: 0;
  background: #000;
}
.remote-video video {
  object-fit: cover;
}
.local-video {
  position: absolute;
  top: max(env(safe-area-inset-top), 16px);
  right: 16px;
  width: 110px;
  height: 160px;
  border-radius: 12px;
  overflow: hidden;
  background: #1a2138;
  border: 1px solid #2a3252;
  z-index: 2;
}
.call-info {
  position: absolute;
  top: max(env(safe-area-inset-top), 16px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.45);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 2;
  max-width: 50%;
  text-align: center;
  word-break: break-all;
}
.avatar.spin {
  animation: spin 1.2s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.controls {
  position: absolute;
  bottom: max(env(safe-area-inset-bottom), 24px);
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 16px;
  z-index: 3;
}
.ctrl {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.ctrl .ci {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font-size: 24px;
  line-height: 1;
}
.ctrl > span:not(.ci) {
  font-size: 10px;
  margin-top: 3px;
}
/* 关闭状态：在图标上画一条红色斜杠 */
.ctrl.slashed .ci::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 3px;
  background: var(--danger);
  border-radius: 2px;
  transform: translate(-50%, -50%) rotate(-45deg);
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.4);
}
.ctrl.hangup {
  background: var(--danger);
}
.ctrl.active {
  background: rgba(255, 79, 94, 0.25);
}

.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 100;
  max-width: 80%;
  text-align: center;
}

/* 安装到桌面提示条 */
.install-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: #1d2640;
  border-top: 1px solid #2a3252;
  z-index: 250;
}
.install-text {
  flex: 1;
  font-size: 14px;
  color: var(--text);
}
.install-go {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  flex: none;
}
.install-x {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  padding: 4px 6px;
  cursor: pointer;
  flex: none;
}
.install-banner.warn {
  background: #3a2a14;
  border-top-color: #7a5a1a;
}
.install-banner.warn .install-text {
  color: #ffd591;
}

/* 诊断入口（左上角文字按钮，避开底部控制条与麦克风按钮） */
.diag-chip {
  position: fixed;
  left: 12px;
  top: max(env(safe-area-inset-top), 12px);
  padding: 6px 12px;
  border-radius: 16px;
  border: 1px solid #2a3252;
  background: rgba(20, 26, 48, 0.7);
  color: var(--muted);
  font-size: 13px;
  z-index: 300;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.debug-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 45vh;
  background: #0a0e1a;
  border-top: 2px solid var(--accent);
  z-index: 301;
  display: flex;
  flex-direction: column;
}
.debug-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid #232a45;
  font-size: 14px;
}
.debug-actions {
  display: flex;
  gap: 8px;
}
.debug-actions button {
  background: #2a3252;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.debug-log {
  flex: 1;
  margin: 0;
  padding: 10px 12px;
  overflow-y: auto;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
  color: #b8c0d8;
  white-space: pre-wrap;
  word-break: break-all;
}
