* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #0f172a; color: #e2e8f0; min-height: 100vh;
}

/* 房间入口 */
.app {
  max-width: 520px; margin: 8vh auto 0; background: #1e293b; border-radius: 12px;
  padding: 32px; box-shadow: 0 10px 30px rgba(0,0,0,.3);
}
h1 { font-size: 24px; font-weight: 600; margin-bottom: 10px; }
.subtitle { color: #94a3b8; font-size: 14px; line-height: 1.7; margin-bottom: 26px; }
#login-view label { display: block; font-size: 14px; color: #cbd5e1; margin-bottom: 8px; }
#room-input {
  width: 100%; padding: 13px 14px; font-size: 16px; border-radius: 8px;
  border: 1px solid #334155; background: #0f172a; color: #e2e8f0; outline: none;
}
#room-input:focus { border-color: #38bdf8; }
#join-btn {
  margin-top: 16px; width: 100%; padding: 13px; font-size: 15px; font-weight: 600;
  border: none; border-radius: 8px; background: #0ea5e9; color: #fff; cursor: pointer;
}
#join-btn:hover { background: #0284c7; }
#join-btn:disabled { opacity: .6; cursor: wait; }
#login-error { color: #f87171; font-size: 13px; margin-top: 12px; min-height: 18px; }

/* 房间视图 */
#room-view { height: 100vh; display: flex; flex-direction: column; padding: 14px; gap: 12px; }
.room-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.room-meta { display: flex; align-items: center; gap: 18px; font-size: 14px; color: #94a3b8; flex-wrap: wrap; }
.room-meta b { color: #38bdf8; }
.room-actions { display: flex; gap: 8px; }
.small-btn {
  border: 1px solid #334155; background: #1e293b; color: #cbd5e1; border-radius: 7px;
  padding: 7px 12px; font-size: 12px; cursor: pointer;
}
.small-btn:hover { background: #334155; }
.small-btn.leave { color: #fca5a5; border-color: #7f1d1d; }
.waiting-tip { color: #94a3b8; font-size: 13px; text-align: center; padding: 4px; }

.video-grid {
  flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 12px;
}
.video-tile {
  position: relative; min-height: 160px; overflow: hidden; border-radius: 12px;
  border: 1px solid #334155; background: #020617;
}
.video-tile video { width: 100%; height: 100%; object-fit: cover; }
#local-video { transform: scaleX(-1); }
.audio-placeholder {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 10px;
  align-items: center; justify-content: center; color: #64748b; font-size: 13px;
  background: #111c30;
}
.audio-icon { font-size: 42px; filter: grayscale(1); opacity: .65; }
.tile-label {
  position: absolute; top: 10px; left: 10px; background: rgba(2,6,23,.75); color: #e2e8f0;
  border-radius: 6px; padding: 4px 9px; font-size: 12px; z-index: 2;
}
.peer-state { color: #94a3b8; margin-left: 6px; }
.tile-stats {
  position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 2;
  background: rgba(2,6,23,.78); color: #94a3b8; border-radius: 6px; padding: 5px 8px;
  font-size: 11px; line-height: 1.5; cursor: pointer; word-break: break-all;
}
.tile-stats:hover { color: #e2e8f0; }
.peer-detail {
  margin-top: 4px; padding-top: 4px; border-top: 1px solid #334155;
  font-family: Consolas, monospace; white-space: pre-wrap; color: #64748b;
}

.room-controls { display: flex; justify-content: center; gap: 16px; padding: 2px 0 6px; }
.ctrl-btn {
  width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
  font-size: 22px; display: flex; align-items: center; justify-content: center;
  background: #334155; color: #fff; transition: background .15s, transform .1s;
}
.ctrl-btn:hover { background: #475569; }
.ctrl-btn:active { transform: scale(.94); }
.ctrl-btn.active-off { background: #64748b; opacity: .65; }

#toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #e2e8f0; padding: 10px 20px; border-radius: 8px;
  font-size: 14px; z-index: 100; box-shadow: 0 6px 20px rgba(0,0,0,.4); border: 1px solid #334155;
}
.hidden { display: none !important; }

@media (max-width: 700px) {
  .app { margin: 3vh 14px 0; padding: 24px; }
  #room-view { padding: 8px; gap: 8px; }
  .video-grid { gap: 8px; }
  .room-meta { gap: 10px; font-size: 12px; }
  .tile-stats { font-size: 10px; }
}
