:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #070a12;
  color: #f5f7fb;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #070a12;
}

button { font: inherit; }

.app-shell {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: #070a12;
}

.video-stage {
  position: relative;
  width: min(100vw, calc(100vh * 9 / 16));
  height: min(100vh, calc(100vw * 16 / 9));
  max-width: 100vw;
  max-height: 100vh;
  overflow: hidden;
  background: #000;
}

#remote-video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}

.shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(0,0,0,.62), transparent 22%, transparent 68%, rgba(0,0,0,.76));
}

.status-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 14px;
  font-size: 14px;
  z-index: 2;
}

.brand { font-weight: 750; letter-spacing: .03em; }
.status { color: #d4dcf2; text-align: right; }

.start-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
  background: radial-gradient(circle at 50% 38%, #192644 0, #0b1020 45%, #070a12 78%);
  z-index: 1;
}

.start-panel img { border-radius: 24px; box-shadow: 0 18px 50px rgba(17, 108, 255, .3); }
.start-panel h1 { margin: 24px 0 8px; font-size: 25px; }
.start-panel > p { margin: 0; color: #b9c3dc; line-height: 1.55; }

.pair-code-form {
  width: min(100%, 310px);
  margin-top: 24px;
}

.pair-code-form label {
  display: block;
  margin-bottom: 10px;
  color: #dce4f7;
  font-size: 14px;
}

.pair-code-form input {
  width: 100%;
  height: 54px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 14px;
  outline: none;
  background: rgba(0,0,0,.35);
  color: #fff;
  text-align: center;
  font: 700 24px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.pair-code-form input:focus { border-color: #4f91ff; }

.code-submit {
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: #176dff;
  font-weight: 700;
}

.primary, .audio-permission {
  min-width: 180px;
  min-height: 50px;
  margin: 28px 0 14px;
  border: 0;
  border-radius: 999px;
  color: white;
  background: #176dff;
  box-shadow: 0 10px 32px rgba(23,109,255,.36);
  font-weight: 700;
}

.primary:disabled { opacity: .45; box-shadow: none; }
.privacy { max-width: 310px; font-size: 12px; opacity: .78; }

.remote-mode-control {
  width: min(100%, 330px);
  margin-top: 22px;
  padding: 12px 14px;
  border: 1px solid rgba(255,183,77,.42);
  border-radius: 14px;
  background: rgba(74,45,6,.55);
  display: flex;
  align-items: flex-start;
  gap: 11px;
  text-align: left;
}

.remote-mode-control input { width: 22px; height: 22px; margin: 1px 0 0; }
.remote-mode-control strong { display: block; color: #fff1d8; font-size: 14px; }
.remote-mode-control small { display: block; margin-top: 4px; color: #e4cfad; line-height: 1.4; }
.remote-mode-control:has(input:checked) { background: rgba(117,55,9,.88); }

.remote-mode-indicator {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 54px);
  right: 18px;
  margin: 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(163,71,7,.92);
  color: #fff1d8;
  font-size: 12px;
  z-index: 2;
}

.controls {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.controls button {
  min-height: 72px;
  border: 1px solid rgba(255,255,255,.17);
  border-radius: 18px;
  color: #fff;
  background: rgba(18,24,39,.78);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
}

.controls button[aria-pressed="false"] { background: rgba(174,43,55,.82); }
.control-icon { font-size: 20px; font-weight: 800; }

.notice {
  position: absolute;
  left: 18px;
  right: 18px;
  top: calc(env(safe-area-inset-top) + 58px);
  padding: 12px 14px;
  border: 1px solid rgba(255,183,77,.42);
  border-radius: 12px;
  background: rgba(74,45,6,.9);
  color: #fff1d8;
  font-size: 13px;
  line-height: 1.45;
  z-index: 3;
}

.audio-permission {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 110px);
  transform: translateX(-50%);
  margin: 0;
}

.diagnostic {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 54px);
  left: 18px;
  margin: 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,.58);
  color: #c8f5d8;
  font-size: 12px;
  z-index: 2;
}

[hidden] { display: none !important; }

@media (orientation: landscape) {
  .video-stage { width: calc(100vh * 9 / 16); height: 100vh; }
}
