*,
*::before,
*::after {
  box-sizing: border-box;
}

/* 必须放在所有 display 规则之前并加 !important：浏览器内置的
   [hidden] { display: none } 来自 UA 样式表，会被作者样式里的
   `section { display: flex }`、`#view-call { position: fixed }` 之类盖掉，
   结果就是"属性设了 hidden、元素照样显示"——全屏的通话视图会一直盖在
   密码框上面。这条是让 hidden 真正生效的唯一保险。 */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #000;
  color: #eee;
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 24px) 20px calc(env(safe-area-inset-bottom) + 24px);
}

h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #bbb;
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
}

section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 360px;
}

label {
  font-size: 14px;
  color: #999;
}

input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  font-size: 17px;
  color: #eee;
  background: #161616;
  border: 1px solid #333;
  border-radius: 10px;
  outline: none;
}

input[type="password"]:focus {
  border-color: #4a8cff;
}

button {
  min-height: 44px;
  padding: 12px 18px;
  font-size: 16px;
  font-family: inherit;
  color: #eee;
  background: #222;
  border: 1px solid #333;
  border-radius: 10px;
  cursor: pointer;
}

button:active {
  background: #2c2c2c;
}

button.primary {
  background: #2f6fed;
  border-color: #2f6fed;
  font-weight: 600;
}

button.primary:active {
  background: #2860d4;
}

button.danger {
  color: #ff8080;
  border-color: #4a2020;
}

.hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #777;
}

#status-text {
  margin: 0;
  font-size: 17px;
  line-height: 1.6;
  text-align: center;
  white-space: pre-wrap;
}

#view-call {
  position: fixed;
  inset: 0;
  max-width: none;
  padding: 0;
  gap: 0;
}

#remote {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #111;
}

#local {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 12px);
  right: 12px;
  width: 28vw;
  max-width: 160px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 10px;
  background: #222;
  transform: scaleX(-1);
}

#signal-notice {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 12px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  font-size: 13px;
  color: #ffd479;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid #5a4a20;
  border-radius: 999px;
  z-index: 5;
}

#controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 16px 12px calc(env(safe-area-inset-bottom) + 16px);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85), transparent);
}

#controls button {
  flex: 1 1 0;
  max-width: 110px;
  font-size: 14px;
}

#diagnostics {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100vw);
  max-height: 100dvh;
  padding: 14px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  color: #b9f6ca;
  background: rgba(8, 12, 10, 0.97);
  border-left: 1px solid #234;
  z-index: 10;
}

#diagnostics dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  margin: 0 0 12px;
}

#diagnostics dt {
  color: #6b8f7a;
}

#diagnostics dd {
  margin: 0;
  word-break: break-all;
}

#diagnostics h3 {
  margin: 0 0 6px;
  font-size: 12px;
  color: #6b8f7a;
}

#diagnostics pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}
