:root {
  --bg: #ededed;
  --header: #f7f7f7;
  --me-bubble: #95ec69;
  --them-bubble: #ffffff;
  --text: #1a1a1a;
  --muted: #9a9a9a;
  --accent: #07c160;
  --danger: #fa5151;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei',
    sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
}

.view {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}
.hidden {
  display: none !important;
}

/* ============ 登录页 ============ */
.login-view {
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #d7f0e3, #eef3f8);
}
.login-card {
  width: 86%;
  max-width: 360px;
  background: #fff;
  border-radius: 18px;
  padding: 32px 24px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  text-align: center;
}
.login-logo {
  font-size: 48px;
}
.login-title {
  margin: 8px 0 4px;
  font-size: 24px;
}
.login-sub {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
}
.login-input {
  width: 100%;
  padding: 13px 14px;
  margin-bottom: 12px;
  border: 1px solid #e3e3e3;
  border-radius: 10px;
  font-size: 16px;
  outline: none;
}
.login-input:focus {
  border-color: var(--accent);
}
.login-btn {
  width: 100%;
  padding: 13px;
  margin-top: 4px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}
.login-btn:active {
  opacity: 0.85;
}
.login-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin: 10px 0 0;
}
.login-hint {
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}
.login-hint code {
  background: #f2f2f2;
  padding: 1px 6px;
  border-radius: 4px;
}

/* ============ 聊天页 ============ */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: var(--header);
  border-bottom: 1px solid #e2e2e2;
  position: sticky;
  top: 0;
  z-index: 5;
}
.chat-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 17px;
  font-weight: 600;
}
.status {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}
.status.online {
  color: var(--accent);
}
.badge {
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  border-radius: 9px;
  padding: 0 5px;
  text-align: center;
  font-weight: 600;
}
.call-btn {
  border: none;
  background: transparent;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px calc(14px + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
}
.msg-row {
  display: flex;
  margin-bottom: 14px;
}
.msg-row.me {
  justify-content: flex-end;
}
.msg-row.them {
  justify-content: flex-start;
}
.bubble {
  max-width: 72%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 16px;
  line-height: 1.45;
  word-break: break-word;
  position: relative;
}
.msg-row.them .bubble {
  background: var(--them-bubble);
  border-top-left-radius: 4px;
}
.msg-row.me .bubble {
  background: var(--me-bubble);
  border-top-right-radius: 4px;
}
.bubble .meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}
.bubble audio {
  display: block;
  max-width: 220px;
}
.bubble .photo {
  display: block;
  max-width: 200px;
  max-height: 280px;
  border-radius: 8px;
}

/* 输入栏 */
.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px calc(8px + var(--safe-bottom));
  background: var(--header);
  border-top: 1px solid #e2e2e2;
}
.composer-btn {
  border: none;
  background: #fff;
  border-radius: 10px;
  font-size: 20px;
  width: 42px;
  height: 42px;
  cursor: pointer;
  flex: 0 0 auto;
}
.composer-input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border: 1px solid #e3e3e3;
  border-radius: 10px;
  font-size: 16px;
  outline: none;
  background: #fff;
}
.composer-input:focus {
  border-color: var(--accent);
}
.send-btn {
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  width: auto;
  padding: 0 16px;
}
.voice-hold {
  flex: 1;
  min-width: 0;
  width: auto;
  background: #fff;
  border: 1px solid #e3e3e3;
  border-radius: 10px;
  font-size: 15px;
  color: #1a1a1a;
  font-weight: 500;
}
.voice-hold.recording {
  background: #dcdcdc;
  color: var(--accent);
  animation: pulse 1s infinite;
}
.mode-btn {
  font-size: 20px;
}
@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

.rec-hint {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 20px;
  z-index: 20;
}

/* ============ 通话浮层 ============ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 25, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.call-card {
  text-align: center;
  color: #fff;
  width: 86%;
  max-width: 340px;
}
.call-avatar {
  font-size: 72px;
  margin-bottom: 14px;
}
.call-name {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 6px;
}
.call-status {
  color: #cfd2d6;
  font-size: 15px;
  margin-bottom: 4px;
}
.call-timer {
  font-size: 32px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  margin-bottom: 40px;
}
.call-actions {
  display: flex;
  justify-content: center;
  gap: 40px;
}
.call-action {
  border: none;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  font-size: 14px;
  color: #fff;
  cursor: pointer;
}
.btn-accept {
  background: var(--accent);
}
.btn-reject,
.btn-hangup {
  background: var(--danger);
}
