/* 云娃 - 移动端优先 */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: #fff5f5;
  color: #333;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

input, textarea { user-select: text; }

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }

:root {
  --primary: #FF6B6B;
  --primary-dark: #E5566B;
  --bg: #fff5f5;
  --card: #ffffff;
  --text: #333;
  --text-light: #888;
  --border: #eee;
  --bubble-me: linear-gradient(135deg, #FF6B6B 0%, #FF9090 100%);
  --bubble-other: #f0f0f0;
}

.page {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding-top: env(safe-area-inset-top);
  padding-bottom: calc(env(safe-area-inset-bottom) + 56px);
}

/* ============= 登录页 ============= */
.login-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 30px 28px 40px;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
}

.logo {
  font-size: 56px;
  font-weight: 800;
  text-align: center;
  background: linear-gradient(135deg, #FF6B6B 0%, #FFB199 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 4px;
  margin-bottom: 8px;
}

.tagline {
  text-align: center;
  color: var(--text-light);
  font-size: 14px;
  margin-bottom: 48px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  height: 50px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 0 16px;
  font-size: 16px;
  background: var(--card);
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.code-input-row {
  display: flex;
  gap: 10px;
}

.code-input-row input {
  flex: 1;
}

.btn-send {
  height: 50px;
  padding: 0 16px;
  background: #FFE5E5;
  color: var(--primary);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: opacity 0.2s;
}

.btn-send:disabled {
  opacity: 0.5;
  color: var(--text-light);
  background: #f0f0f0;
}

.btn-primary {
  height: 52px;
  background: linear-gradient(135deg, #FF6B6B 0%, #FF8E8E 100%);
  color: #fff;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(255, 107, 107, 0.3);
  transition: transform 0.1s, box-shadow 0.2s;
}

.btn-primary:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
}

.btn-primary:disabled {
  opacity: 0.6;
}

.btn-secondary {
  height: 52px;
  background: var(--card);
  color: var(--text);
  border-radius: 14px;
  font-size: 17px;
  font-weight: 600;
  border: 1.5px solid var(--border);
  margin-top: 12px;
}

.tip {
  margin-top: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-light);
  min-height: 20px;
}

.tip.error { color: var(--primary); }

.dev-tip {
  margin-top: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-light);
  background: #fff8e1;
  padding: 8px 12px;
  border-radius: 8px;
}

/* ============= 顶栏 ============= */
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.me-info, .peer-info {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
  text-align: center;
}

.btn-back {
  width: 36px;
  height: 36px;
  font-size: 24px;
  color: var(--text);
}

.btn-text {
  font-size: 14px;
  color: var(--text-light);
  padding: 6px 10px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  font-size: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
  transition: transform 0.1s;
}

.btn-icon:active { transform: scale(0.95); }

.btn-record.recording {
  background: var(--primary);
  color: #fff;
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* ============= 匹配页 ============= */
.match-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.match-card {
  width: 100%;
  max-width: 340px;
  background: var(--card);
  border-radius: 28px;
  padding: 48px 32px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(255, 107, 107, 0.1);
}

.match-icon {
  font-size: 80px;
  margin-bottom: 24px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.match-card h2 {
  font-size: 26px;
  color: var(--text);
  margin-bottom: 12px;
}

.match-desc {
  font-size: 15px;
  color: var(--text-light);
  line-height: 1.6;
}

.match-card.searching .match-icon {
  animation: spin 2s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.match-actions {
  padding: 20px 24px calc(20px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--border);
}

.btn-large {
  width: 100%;
  font-size: 18px;
}

/* ============= 聊天页 ============= */
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

.msg-row {
  display: flex;
  margin-bottom: 12px;
  align-items: flex-end;
}

.msg-row.me { justify-content: flex-end; }
.msg-row.other { justify-content: flex-start; }

.bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 16px;
  line-height: 1.4;
  word-break: break-word;
  position: relative;
}

.msg-row.me .bubble {
  background: var(--bubble-me);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-row.other .bubble {
  background: var(--bubble-other);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.bubble-time {
  font-size: 10px;
  opacity: 0.6;
  margin-top: 4px;
  text-align: right;
}

.msg-row.other .bubble-time { text-align: left; }

.bubble.voice {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 100px;
}

.bubble.voice .wave {
  font-size: 14px;
  letter-spacing: 1px;
}

.bubble.voice.playing .wave {
  animation: wave 0.6s linear infinite;
}

@keyframes wave {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.bubble.system {
  background: #fff8e1;
  color: #b07a1d;
  font-size: 13px;
  max-width: 80%;
  text-align: center;
  margin: 8px auto;
  padding: 6px 12px;
  border-radius: 12px;
}

.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--border);
}

#msg-input {
  flex: 1;
  height: 40px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 0 16px;
  font-size: 16px;
  background: #f8f8f8;
}

#msg-input:focus { outline: none; border-color: var(--primary); background: #fff; }

/* ============= 通话弹窗 ============= */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.call-box {
  text-align: center;
  color: #fff;
  padding: 40px;
}

.call-avatar {
  font-size: 100px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: float 3s ease-in-out infinite;
}

.call-status {
  font-size: 18px;
  margin-bottom: 8px;
}

.call-time {
  font-size: 32px;
  font-weight: 300;
  letter-spacing: 2px;
  margin-bottom: 40px;
  font-variant-numeric: tabular-nums;
}

.call-actions {
  display: flex;
  gap: 24px;
  justify-content: center;
}

.btn-call {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  font-size: 32px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.btn-accept { background: #4CAF50; }
.btn-reject { background: #F44336; }

/* ============= Toast ============= */
.toast {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 15px;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  max-width: 80%;
  text-align: center;
}

.toast.show { opacity: 1; }
