:root {
  --bg: #0b0e11;
  --surface: rgba(255, 255, 255, 0.07);
  --surface-2: rgba(255, 255, 255, 0.12);
  --line: rgba(255, 255, 255, 0.14);
  --fg: #f2f5f7;
  --fg-dim: #9aa4ae;
  --accent: #3ddc97;
  --danger: #f05252;
  --warn: #f5a524;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

.hidden {
  display: none !important;
}

.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* ── 视频区 ─────────────────────────────── */

.stage {
  position: absolute;
  inset: 0;
  background: #05070a;
}

#remoteVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #05070a;
}

#localVideo {
  position: absolute;
  right: 12px;
  bottom: calc(104px + env(safe-area-inset-bottom));
  width: 92px;
  height: 124px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #12161a;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  z-index: 3;
  transition: opacity 0.2s;
}

#localVideo.off {
  opacity: 0;
}

.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  z-index: 2;
  background: radial-gradient(circle at 50% 42%, #161d24 0%, #05070a 72%);
}

.placeholder p {
  margin: 0;
  font-size: 14px;
  color: var(--fg-dim);
  letter-spacing: 0.02em;
}

.ring {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 2px solid rgba(61, 220, 151, 0.25);
  position: relative;
}

.ring::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  animation: spin 1.4s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ring::after {
    animation: none;
    border-top-color: var(--accent);
  }
}

/* ── 状态条 ─────────────────────────────── */

.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 14px;
  font-size: 13px;
  color: #d7dde3;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent);
  z-index: 6;
  pointer-events: none;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--fg-dim);
  flex: none;
  transition: background 0.2s;
}

.dot[data-tone="ok"] { background: var(--accent); }
.dot[data-tone="warn"] { background: var(--warn); }
.dot[data-tone="danger"] { background: var(--danger); }
.dot[data-tone="info"] { background: #4ea8de; }

/* ── 传输列表 ───────────────────────────── */

.transfers {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(112px + env(safe-area-inset-bottom));
  max-height: 42vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 5;
  pointer-events: none;
}

.titem {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(18, 22, 26, 0.86);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: 13px;
  animation: rise 0.18s ease-out;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.titem .thumb {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  flex: none;
  background: var(--surface-2);
}

.titem .thumb.plain {
  display: grid;
  place-items: center;
  color: var(--fg-dim);
  font-size: 11px;
}

.titem .body {
  flex: 1;
  min-width: 0;
}

.titem .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--fg);
}

.titem .meta {
  font-size: 11px;
  color: var(--fg-dim);
  margin-top: 3px;
  display: flex;
  gap: 8px;
}

.titem .progress {
  height: 3px;
  border-radius: 2px;
  background: var(--surface-2);
  margin-top: 6px;
  overflow: hidden;
}

.titem .progress i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.15s linear;
}

.titem .act {
  flex: none;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--fg);
  font: inherit;
  font-size: 12px;
  padding: 6px 11px;
  border-radius: 9px;
  cursor: pointer;
  text-decoration: none;
}

.titem .act:active {
  transform: scale(0.96);
}

/* ── 控制栏 ─────────────────────────────── */

.bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 6px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.88), rgba(0, 0, 0, 0.45) 60%, transparent);
  z-index: 7;
}

.ctl {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 2px;
  border: 0;
  background: none;
  color: #cdd5dc;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  border-radius: 12px;
  transition: color 0.15s, background 0.15s;
}

.ctl .ico {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ctl:active {
  background: var(--surface);
}

.ctl.off {
  color: var(--danger);
}

.ctl.danger {
  color: #ff8a8a;
}

.ctl:disabled {
  opacity: 0.32;
  cursor: default;
}

/* ── 开始 / 挂断遮罩 ────────────────────── */

.gate {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 7, 10, 0.93);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 20;
}

.gate .card {
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.gate h1 {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.gate p {
  margin: 0 0 26px;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--fg-dim);
}

.primary,
.ghost {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary {
  background: var(--accent);
  color: #06231a;
  font-weight: 500;
}

.primary:disabled {
  opacity: 0.6;
  cursor: default;
}

.ghost {
  margin-top: 10px;
  background: var(--surface-2);
  color: var(--fg);
  border: 1px solid var(--line);
}

.ghost .ico {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary:active,
.ghost:active {
  transform: scale(0.985);
}

/* ── 横屏 ───────────────────────────────── */

@media (orientation: landscape) and (min-width: 640px) {
  #localVideo {
    width: 132px;
    height: 176px;
    right: 20px;
    bottom: calc(90px + env(safe-area-inset-bottom));
  }
  .transfers {
    left: auto;
    width: 340px;
    right: 20px;
  }
}
