/* lovechat v4 — 夜空风精修版 */

:root {
  /* 背景渐变层级 */
  --bg-base: #0a0b1e;
  --bg-1: #1a1244;
  --bg-2: #2d1b5e;
  --bg-3: #4f1d6e;
  --bg-4: #1e2a78;

  /* 强调色 */
  --accent-purple: #a855f7;
  --accent-pink: #ec4899;
  --accent-indigo: #6366f1;
  --accent-blush: #f0abfc;

  /* 文字梯度(更细致) */
  --text-strong: rgba(255, 255, 255, 1);
  --text-primary: rgba(255, 255, 255, 0.92);
  --text-secondary: rgba(255, 255, 255, 0.68);
  --text-tertiary: rgba(255, 255, 255, 0.42);
  --text-faint: rgba(255, 255, 255, 0.22);

  /* 表面层(分层, 不依赖 backdrop-filter) */
  --surface: rgba(255, 255, 255, 0.05);
  --surface-hover: rgba(255, 255, 255, 0.09);
  --surface-strong: rgba(255, 255, 255, 0.11);
  --surface-glass: rgba(255, 255, 255, 0.06); /* 配合 backdrop-filter 用 */
  --divider: rgba(255, 255, 255, 0.08);
  --divider-strong: rgba(255, 255, 255, 0.14);

  /* 边框 */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-default: rgba(255, 255, 255, 0.14);
  --border-strong: rgba(255, 255, 255, 0.22);
  --border-accent: rgba(168, 85, 247, 0.5);

  /* 渐变 */
  --grad-primary: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
  --grad-mine: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
  --grad-mine-deep: linear-gradient(135deg, #9333ea 0%, #db2777 100%);
  --grad-brand: linear-gradient(135deg, #f0abfc 0%, #a855f7 50%, #ec4899 100%);
  /* 背景加一层径向探照灯(月光从左上漏进来) */
  --grad-bg: radial-gradient(ellipse 80% 50% at 30% 0%, rgba(236, 72, 153, 0.08) 0%, transparent 60%),
            radial-gradient(ellipse 60% 40% at top left, var(--bg-4) 0%, transparent 55%),
            radial-gradient(ellipse 70% 50% at bottom right, var(--bg-3) 0%, transparent 55%),
            linear-gradient(160deg, var(--bg-base) 0%, var(--bg-1) 50%, var(--bg-2) 100%);

  /* 阴影 - 五档分层 */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.18);
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.22);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 20px 56px rgba(0, 0, 0, 0.42);
  --shadow-glow: 0 0 32px rgba(168, 85, 247, 0.35);
  --shadow-glow-strong: 0 0 48px rgba(236, 72, 153, 0.5);
  --shadow-mine: 0 8px 24px rgba(168, 85, 247, 0.45);
  /* 顶部高光(让卡片"实体化") */
  --inset-hairline: inset 0 1px 0 rgba(255, 255, 255, 0.1);

  /* 圆角 */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-full: 999px;

  /* 缓动 */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

/* ===== 重置 ===== */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'SF Pro Text', 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg-base);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* 字体角色分配:
 * - display/serif: Instrument Serif(品牌字, 标题)
 * - display/sans:  Instrument Sans(数字、强调)
 * - body:          系统字体栈(中文优先 PingFang SC)
 * - mono:          系统等宽(时间戳等数据)
 */
.font-display-serif { font-family: 'Instrument Serif', Georgia, 'Times New Roman', serif; }
.font-display-sans  { font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, sans-serif; }

body {
  background: var(--grad-bg);
  background-attachment: fixed;
  position: relative;
}

/* 静态星点层 — 模拟夜空(60s 缓慢呼吸, 让背景"活"起来) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(1px 1px at 12% 18%, rgba(240, 171, 252, 0.8), transparent),
    radial-gradient(1px 1px at 24% 62%, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1.5px 1.5px at 36% 28%, rgba(168, 85, 247, 0.7), transparent),
    radial-gradient(1px 1px at 48% 82%, rgba(240, 171, 252, 0.6), transparent),
    radial-gradient(1px 1px at 58% 12%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1.5px 1.5px at 68% 48%, rgba(236, 72, 153, 0.6), transparent),
    radial-gradient(1px 1px at 78% 78%, rgba(255, 255, 255, 0.6), transparent),
    radial-gradient(1px 1px at 88% 32%, rgba(240, 171, 252, 0.7), transparent),
    radial-gradient(1.5px 1.5px at 92% 68%, rgba(168, 85, 247, 0.5), transparent),
    radial-gradient(1px 1px at 8% 92%, rgba(255, 255, 255, 0.6), transparent);
  background-size: 100% 100%;
  opacity: 0.85;
  animation: starsBreathe 60s ease-in-out infinite;
}
@keyframes starsBreathe {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.hidden { display: none !important; }

/* ===== 登录页 Lobby ===== */
.lobby {
  position: relative;
  z-index: 1;
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  animation: fadeUp 600ms var(--ease-out);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.lobby-card {
  width: 100%;
  max-width: 380px;
  padding: 40px 28px 28px;
  border-radius: var(--r-xl);
  background: var(--surface-glass);
  backdrop-filter: blur(28px) saturate(170%);
  -webkit-backdrop-filter: blur(28px) saturate(170%);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-md), var(--inset-hairline);
  position: relative;
}

.language-switcher {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 3px;
  margin: -20px auto 24px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
}

.language-option {
  min-width: 0;
  padding: 8px 7px;
  border: 0;
  border-radius: var(--r-full);
  color: var(--text-secondary);
  background: transparent;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color 180ms var(--ease-out), background 180ms var(--ease-out), box-shadow 180ms var(--ease-out);
}

.language-option:hover { color: var(--text-primary); background: var(--surface); }
.language-option.active {
  color: white;
  background: var(--grad-primary);
  box-shadow: 0 4px 14px rgba(168, 85, 247, 0.35), var(--inset-hairline);
}

.brand {
  text-align: center;
  margin-bottom: 32px;
}

.brand-name {
  font-family: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-weight: 400;
  font-size: 46px;
  line-height: 1;
  letter-spacing: -1.5px;
  margin: 0;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  /* 微微发光, 让字"跳"出来 */
  filter: drop-shadow(0 0 12px rgba(236, 72, 153, 0.25));
}

.brand-sub {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: 2.5px;
  text-transform: lowercase;
  font-weight: 500;
}

.field {
  display: block;
  margin-bottom: 18px;
}

.field-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.field-input {
  width: 100%;
  padding: 13px 14px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  outline: none;
  transition: all 200ms var(--ease-out);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
}

.field-input::placeholder {
  color: var(--text-tertiary);
}

.field-input:hover {
  border-color: var(--border-default);
  background: var(--surface-hover);
}

.field-input:focus {
  background: rgba(255, 255, 255, 0.07);
  border-color: transparent;
  box-shadow:
    0 0 0 2px rgba(168, 85, 247, 0.4),
    inset 0 1px 2px rgba(0, 0, 0, 0.15);
}

.btn-primary {
  width: 100%;
  padding: 15px;
  margin-top: 10px;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 2px;
  color: white;
  font-family: inherit;
  background: var(--grad-primary);
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  box-shadow: var(--shadow-glow), var(--inset-hairline);
  transition: all 220ms var(--ease-out);
  position: relative;
  overflow: hidden;
}

/* 按钮顶部高光(让按钮"立体") */
.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18) 0%, transparent 50%);
  pointer-events: none;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow-strong), var(--inset-hairline);
}

.btn-primary:active {
  transform: scale(0.98);
  background: var(--grad-mine-deep);
}

.hint {
  margin: 16px 0 0;
  font-size: 11.5px;
  color: var(--text-tertiary);
  text-align: center;
  line-height: 1.6;
}

/* ===== 主界面 ===== */
.app {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 640px;
  margin: 0 auto;
}

/* ===== 顶栏 ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top) + 12px) 14px 12px;
  background: rgba(10, 11, 30, 0.55);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
  z-index: 5;
  box-shadow: var(--inset-hairline); /* 底部高光让顶栏更精致 */
}

.back {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--r-full);
  transition: background 150ms;
}
.back:active { background: var(--surface); }

.peer {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.peer-avatar {
  width: 40px; height: 40px;
  border-radius: var(--r-full);
  flex: 0 0 auto;
  display: grid; place-items: center;
  font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: white;
  background: var(--grad-primary);
  overflow: hidden;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.12),
    0 4px 12px rgba(168, 85, 247, 0.25);
  position: relative;
}
.peer-avatar img {
  width: 100%; height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.peer-info { min-width: 0; flex: 1; }
.peer-name {
  font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.1px;
}
.peer-status {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 2px;
  display: flex; align-items: center; gap: 6px;
}
.peer-status::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  transition: all 200ms;
}
.peer-status.online { color: #7ee8b3; }
.peer-status.online::before {
  background: #7ee8b3;
  box-shadow:
    0 0 8px #7ee8b3,
    0 0 16px rgba(126, 232, 179, 0.4);
  animation: onlinePulse 2s ease-in-out infinite;
}
@keyframes onlinePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.85; }
}

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  font-size: 18px;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--r-full);
  cursor: pointer;
  transition: all 200ms var(--ease-out);
}
.icon-btn:hover { background: var(--surface); color: var(--text-primary); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn.ringing { animation: ringPulse 1.4s ease-in-out infinite; }

@keyframes ringPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.6); }
  50% { box-shadow: 0 0 0 10px rgba(168, 85, 247, 0); }
}

.icon-btn.primary {
  background: var(--grad-primary);
  color: white;
  box-shadow: var(--shadow-glow);
}
.icon-btn.primary:hover { transform: translateY(-1px); }

.language-select {
  width: 48px;
  height: 32px;
  flex: 0 0 auto;
  padding: 0 5px;
  border: 1px solid var(--border-default);
  border-radius: var(--r-full);
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.06);
  font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 10.5px;
  font-weight: 700;
  outline: none;
  cursor: pointer;
}
.language-select:hover,
.language-select:focus { color: var(--text-primary); border-color: var(--border-accent); }
.language-select option { color: #111827; background: white; }

/* ===== 消息区 ===== */
.msg-list {
  flex: 1;
  overflow-y: auto;
  padding: 20px 14px 12px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.msg-list.bg-custom {
  background-image: linear-gradient(rgba(10, 11, 30, 0.7), rgba(10, 11, 30, 0.85)), var(--bg-url);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

.day-divider {
  text-align: center;
  font-size: 11px;
  color: var(--text-tertiary);
  margin: 16px 0 20px;
  letter-spacing: 1px;
  font-family: ui-monospace, 'SF Mono', monospace;
}

/* 消息行 */
.msg {
  display: flex;
  margin-bottom: 16px;
  align-items: flex-end;
  gap: 10px;
  animation: msgIn 380ms var(--ease-spring);
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px) scale(0.94); }
  to { opacity: 1; transform: none; }
}

.msg.mine { flex-direction: row-reverse; }

.msg .avatar {
  width: 36px; height: 36px;
  border-radius: var(--r-full);
  flex: 0 0 auto;
  display: grid; place-items: center;
  font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px; font-weight: 600;
  color: white;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  overflow: hidden;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.08),
    0 2px 8px rgba(0, 0, 0, 0.25);
}
.msg.mine .avatar {
  background: var(--grad-primary);
  box-shadow:
    0 0 0 2px rgba(168, 85, 247, 0.25),
    0 2px 8px rgba(168, 85, 247, 0.3);
}
.msg .avatar img { width: 100%; height: 100%; object-fit: cover; }

.msg .body {
  max-width: 72%;
  display: flex;
  flex-direction: column;
}

.msg.mine .body { align-items: flex-end; }

.msg .meta {
  font-size: 10.5px;
  color: var(--text-tertiary);
  margin: 0 6px 5px;
  font-family: ui-monospace, 'SF Mono', monospace;
  letter-spacing: 0.6px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.msg .meta::before {
  content: '';
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: var(--text-faint);
}

/* 气泡 — 核心签名元素 */
.msg .bubble {
  position: relative;
  padding: 11px 15px;
  border-radius: var(--r-lg);
  font-size: 15px;
  line-height: 1.65;
  word-break: break-word;
  white-space: pre-wrap;
  overflow: hidden;
  letter-spacing: 0.1px;
}

/* 星点 — 签名元素 */
.msg .bubble::before {
  content: '';
  position: absolute;
  top: 9px;
  left: 11px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent-blush);
  box-shadow: 0 0 6px var(--accent-blush), 0 0 12px rgba(240, 171, 252, 0.5);
  opacity: 0.9;
}
.msg.mine .bubble::before {
  left: auto;
  right: 11px;
  background: white;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.9), 0 0 12px rgba(255, 255, 255, 0.4);
}

/* 星点轨迹 — 拖尾线(更细、更发光) */
.msg .bubble::after {
  content: '';
  position: absolute;
  top: 10.5px;
  left: 12px;
  width: 18px;
  height: 0.5px;
  background: linear-gradient(90deg, var(--accent-blush) 0%, transparent 100%);
  opacity: 0.55;
  border-radius: 1px;
  filter: blur(0.3px);
}
.msg.mine .bubble::after {
  left: auto;
  right: 12px;
  background: linear-gradient(270deg, rgba(255, 255, 255, 0.85) 0%, transparent 100%);
}

.msg.mine .bubble {
  background: var(--grad-mine);
  color: white;
  border-bottom-right-radius: 6px;
  /* 有色辉光 + 顶部高光, 让气泡"浮"起来 */
  box-shadow: var(--shadow-mine), var(--inset-hairline);
}

.msg.peer .bubble {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-primary);
  /* 双层边框: 内浅外暗, 模拟磨砂玻璃厚度 */
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-xs), var(--inset-hairline);
}

/* 图片气泡 */
.msg .bubble.image {
  padding: 4px;
  background: transparent !important;
  border: none !important;
  backdrop-filter: none;
}
.msg .bubble.image::before, .msg .bubble.image::after { display: none; }

.msg .bubble.image img {
  display: block;
  max-width: 220px;
  max-height: 280px;
  border-radius: var(--r-md);
  cursor: pointer;
}

/* 文件气泡 */
.msg .bubble.file {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  min-width: 140px;
}
.msg .bubble.file .f-icon {
  font-size: 22px;
  opacity: 0.85;
}
.msg .bubble.file .f-name {
  font-size: 13.5px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 语音条 */
.msg .bubble.voice-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  min-width: 90px;
}
.msg .bubble.voice-msg .v-icon {
  font-size: 13px;
  transition: transform 100ms;
}
.msg .bubble.voice-msg.playing .v-icon { transform: scale(1.1); }
.msg .bubble.voice-msg .v-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 18px;
}
.msg .bubble.voice-msg .v-bar i {
  width: 2.5px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.75;
}
.msg .bubble.voice-msg .v-dur {
  font-size: 11px;
  opacity: 0.8;
  font-family: ui-monospace, 'SF Mono', monospace;
}

/* ===== 输入栏 ===== */
.inputbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 12px calc(env(safe-area-inset-bottom) + 12px);
  background: rgba(10, 11, 30, 0.55);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border-top: 1px solid var(--border-subtle);
}

.input-btn {
  width: 38px; height: 38px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  font-size: 17px;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: all 180ms var(--ease-out);
  box-shadow: var(--shadow-xs);
}
.input-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-default);
  color: var(--text-primary);
  transform: translateY(-1px);
}
.input-btn:active { transform: scale(0.92); background: var(--surface-strong); }

.text-input {
  flex: 1; min-width: 0;
  padding: 10px 16px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-full);
  outline: none;
  transition: all 200ms var(--ease-out);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
}
.text-input::placeholder { color: var(--text-tertiary); }
.text-input:hover {
  background: var(--surface-hover);
  border-color: var(--border-default);
}
.text-input:focus {
  background: rgba(255, 255, 255, 0.07);
  border-color: transparent;
  box-shadow:
    0 0 0 2px rgba(168, 85, 247, 0.4),
    inset 0 1px 2px rgba(0, 0, 0, 0.15);
}

.send-btn {
  padding: 9px 18px;
  font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: white;
  background: var(--grad-primary);
  border: none;
  border-radius: var(--r-full);
  cursor: pointer;
  font-family: inherit;
  box-shadow: var(--shadow-glow), var(--inset-hairline);
  transition: all 200ms var(--ease-out);
}
.send-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow-strong), var(--inset-hairline);
}
.send-btn:active { transform: scale(0.95); }

/* 按住说话覆盖层 */
.recording {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(10, 11, 30, 0.92);
  backdrop-filter: blur(16px);
}
.rec-order {
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: 1.5px;
}
.rec-timer {
  font-size: 42px;
  font-weight: 600;
  color: var(--accent-blush);
  font-family: ui-monospace, 'SF Mono', monospace;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 24px rgba(240, 171, 252, 0.5);
}
.recording.cancel { background: rgba(193, 102, 107, 0.85); }
.recording.cancel .rec-order { color: rgba(255, 217, 217, 0.95); }

/* ===== 通话覆盖层 ===== */
.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(10, 11, 30, 0.82);
  backdrop-filter: blur(32px) saturate(150%);
  -webkit-backdrop-filter: blur(32px) saturate(150%);
  animation: fadeIn 280ms var(--ease-out);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.call-card {
  text-align: center;
  padding: 40px 44px;
  border-radius: var(--r-xl);
  background: var(--surface-glass);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg), var(--inset-hairline);
  min-width: 280px;
  position: relative;
}

.call-avatar {
  width: 92px; height: 92px;
  border-radius: var(--r-full);
  margin: 0 auto 18px;
  display: grid; place-items: center;
  font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 38px; font-weight: 600;
  color: white;
  background: var(--grad-primary);
  overflow: hidden;
  position: relative;
  /* 双层光环: 内实光晕 + 外虚扩散 */
  box-shadow:
    0 0 0 4px rgba(168, 85, 247, 0.25),
    0 0 40px rgba(168, 85, 247, 0.45),
    var(--inset-hairline);
  animation: avatarPulse 2.4s ease-in-out infinite;
}
.call-avatar img { width: 100%; height: 100%; object-fit: cover; position: relative; z-index: 1; }

@keyframes avatarPulse {
  0%, 100% {
    box-shadow:
      0 0 0 4px rgba(168, 85, 247, 0.25),
      0 0 40px rgba(168, 85, 247, 0.4),
      var(--inset-hairline);
  }
  50% {
    box-shadow:
      0 0 0 10px rgba(168, 85, 247, 0.1),
      0 0 60px rgba(168, 85, 247, 0.55),
      var(--inset-hairline);
  }
}

/* 通话中头像外加旋转光环(只在 talking 状态, 通过父级 .talking 触发) */
.call-card.talking .call-avatar::after {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 1px dashed rgba(168, 85, 247, 0.35);
  animation: spin 8s linear infinite;
  pointer-events: none;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.call-title {
  font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 21px;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: -0.2px;
}
.call-status {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 32px;
  font-family: ui-monospace, 'SF Mono', monospace;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}
.call-actions {
  display: flex;
  gap: 18px;
  justify-content: center;
}

.call-btn-round {
  width: 62px; height: 62px;
  border-radius: var(--r-full);
  font-size: 22px;
  border: none;
  cursor: pointer;
  color: white;
  display: grid; place-items: center;
  font-family: inherit;
  transition: transform 180ms var(--ease-out);
  box-shadow: var(--shadow-md), var(--inset-hairline);
  position: relative;
  overflow: hidden;
}
.call-btn-round::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, transparent 50%);
  pointer-events: none;
}
.call-btn-round:active { transform: scale(0.94); }

.call-accept {
  background: linear-gradient(135deg, #34d399, #059669);
  box-shadow: 0 8px 24px rgba(52, 211, 153, 0.4), var(--inset-hairline);
}
.call-accept:hover { box-shadow: 0 12px 32px rgba(52, 211, 153, 0.5), var(--inset-hairline); }

.call-reject,
.call-hangup {
  background: linear-gradient(135deg, #f87171, #dc2626);
  box-shadow: 0 8px 24px rgba(248, 113, 113, 0.4), var(--inset-hairline);
}
.call-reject:hover,
.call-hangup:hover { box-shadow: 0 12px 32px rgba(248, 113, 113, 0.5), var(--inset-hairline); }

/* ===== 动态视图 ===== */
.moments {
  flex: 1;
  overflow-y: auto;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  -webkit-overflow-scrolling: touch;
}

.moment-compose {
  background: var(--surface-glass);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm), var(--inset-hairline);
}

.moment-text {
  width: 100%;
  resize: none;
  font-family: inherit;
  font-size: 15px;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--r-md);
  padding: 10px 12px;
  outline: none;
  transition: border-color 200ms;
}
.moment-text::placeholder { color: var(--text-tertiary); }
.moment-text:focus { border-color: rgba(168, 85, 247, 0.4); }

.moment-pics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.moment-pics .pic-x {
  position: relative;
  cursor: pointer;
}
.moment-pics .pic-x img {
  width: 72px; height: 72px;
  object-fit: cover;
  border-radius: var(--r-md);
  display: block;
}
.moment-pics .pic-x::after {
  content: '×';
  position: absolute;
  top: -6px; right: -6px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(10, 11, 30, 0.85);
  color: white;
  font-size: 13px;
  display: grid; place-items: center;
  font-weight: 300;
}

.moment-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}

.moment-card {
  background: var(--surface-glass);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm), var(--inset-hairline);
  animation: msgIn 280ms var(--ease-out);
}

.moment-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.moment-head .avatar {
  width: 40px; height: 40px;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 600; color: white;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  overflow: hidden;
  box-shadow:
    0 0 0 2px rgba(168, 85, 247, 0.2),
    0 2px 8px rgba(168, 85, 247, 0.25);
}
.moment-head .avatar img { width: 100%; height: 100%; object-fit: cover; }

.moment-author { font-size: 14px; font-weight: 600; }
.moment-time {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: ui-monospace, 'SF Mono', monospace;
  margin-top: 1px;
}

.moment-text-body {
  font-size: 14.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.moment-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
.moment-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--r-md);
  cursor: pointer;
}

.moment-like {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: color 200ms;
}
.moment-like.on { color: var(--accent-pink); }
.moment-like.on .heart { animation: heartBeat 360ms var(--ease-spring); }
@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.4); }
}
.like-count { font-variant-numeric: tabular-nums; }

/* ===== 按钮小组件 ===== */
.btn-mini {
  padding: 9px 18px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: var(--r-md);
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: all 200ms var(--ease-out);
  box-shadow: var(--shadow-xs), var(--inset-hairline);
  position: relative;
  overflow: hidden;
}
.btn-mini {
  color: white;
  background: var(--grad-primary);
}
.btn-mini:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm), var(--inset-hairline); }
.btn-mini.ghost {
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border-default);
}
.btn-mini.ghost:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.btn-mini:active { transform: scale(0.96); }

/* ===== 设置面板 ===== */
.settings-card { width: min(92vw, 360px); text-align: left; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--divider);
}
.setting-row:last-of-type { border-bottom: none; }
.setting-label { font-size: 14px; font-weight: 600; }
.setting-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 3px; }

.setting-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar-preview {
  width: 48px; height: 48px;
  border-radius: var(--r-full);
  object-fit: cover;
  background: var(--grad-primary);
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.12),
    0 4px 12px rgba(168, 85, 247, 0.25);
  transition: transform 200ms var(--ease-out);
}
.avatar-preview:hover { transform: scale(1.05); }

/* ===== 图片预览 ===== */
.img-preview {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(8px);
  cursor: zoom-out;
}
.img-preview img {
  max-width: 95vw;
  max-height: 95vh;
  border-radius: var(--r-md);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translate(-50%, 16px);
  padding: 11px 22px;
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--text-primary);
  background: rgba(10, 11, 30, 0.92);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md), var(--inset-hairline);
  opacity: 0;
  pointer-events: none;
  transition: all 260ms var(--ease-out);
  z-index: 70;
  max-width: 85vw;
  text-align: center;
  letter-spacing: 0.3px;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* 打字提示 */
.typing-hint {
  font-size: 11.5px;
  color: var(--text-secondary);
  padding: 0 14px 6px;
  font-style: italic;
}

/* ===== 响应式微调 ===== */
@media (max-width: 400px) {
  .msg .bubble.image img { max-width: 180px; max-height: 240px; }
  .lobby-card { padding: 32px 22px 24px; }
  .brand-name { font-size: 38px; }
  .language-switcher { margin-top: -14px; }
  .language-option { padding-inline: 5px; font-size: 10.5px; }
  .topbar { gap: 5px; padding-inline: 9px; }
  .language-select { width: 42px; padding-inline: 3px; }
  .icon-btn { width: 34px; height: 34px; }
}

/* 减少动画 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== 表情面板 ===== */
.emoji-panel {
  position: absolute;
  left: 12px;
  bottom: calc(100% + 10px);
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  width: min(320px, calc(100vw - 24px));
  padding: 10px;
  background: rgba(20, 16, 45, 0.96);
  backdrop-filter: blur(28px) saturate(170%);
  -webkit-backdrop-filter: blur(28px) saturate(170%);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg), var(--inset-hairline);
}
.emoji-cell {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  font-size: 22px;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms var(--ease-out), transform 100ms;
}
.emoji-cell:hover { background: var(--surface-hover); }
.emoji-cell:active { transform: scale(0.85); }

/* ===== 头像裁剪器 ===== */
.crop-card {
  width: min(94vw, 420px);
  text-align: center;
  padding: 22px;
  border-radius: var(--r-xl);
  background: var(--surface-glass);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg), var(--inset-hairline);
}
.crop-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}
.crop-stage {
  position: relative;
  width: min(82vw, 360px);
  height: min(82vw, 360px);
  margin: 0 auto 14px;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.45);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#cropImg {
  position: absolute;
  max-width: none;
  pointer-events: none;
}
.crop-box {
  position: absolute;
  z-index: 2;
  border: 2px solid white;
  border-radius: 6px;
  box-shadow: 0 0 0 4000px rgba(10, 11, 30, 0.55);
  cursor: move;
}
.crop-grip {
  position: absolute;
  width: 18px; height: 18px;
  pointer-events: none;
}
.grip-nw { left: -2px; top: -2px; border-left: 3px solid white; border-top: 3px solid white; border-top-left-radius: 4px; }
.grip-ne { right: -2px; top: -2px; border-right: 3px solid white; border-top: 3px solid white; border-top-right-radius: 4px; }
.grip-sw { left: -2px; bottom: -2px; border-left: 3px solid white; border-bottom: 3px solid white; border-bottom-left-radius: 4px; }
.grip-se { right: -2px; bottom: -2px; border-right: 3px solid white; border-bottom: 3px solid white; border-bottom-right-radius: 4px; }
.crop-hint {
  position: absolute;
  left: 0; right: 0; bottom: 10px;
  z-index: 3;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}
.crop-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.crop-actions .btn-mini:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* 语音条播放动画(正在播放时波形跳动) */
.msg .bubble.voice-msg.playing .v-bar i {
  animation: voiceWave 800ms ease-in-out infinite;
}
.msg .bubble.voice-msg.playing .v-bar i:nth-child(odd) { animation-delay: 250ms; }
@keyframes voiceWave {
  0%, 100% { height: 5px; }
  50% { height: 15px; }
}
