/* 我们的客厅 — 微信风格聊天, 暖金主题 */
:root {
  --bg: #1b120b;
  --bg-2: #241812;
  --card: #2f2116;
  --card-2: #3a2a1c;
  --gold: #d8a657;
  --gold-2: #b07a36;
  --cream: #f4ece0;
  --cream-dim: #b3a28c;
  --mine-bubble: linear-gradient(160deg, #c99a4e, #a06e2e);
  --peer-bubble: #3a2a1c;
  --danger: #c1666b;
  --ok: #7fb069;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --radius: 14px;
}

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

html, body {
  margin: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
  color: var(--cream);
  background: linear-gradient(170deg, #2a1d12 0%, #150e08 100%);
  background-attachment: fixed;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ===== 登录页 ===== */
.lobby {
  height: 100%; width: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.lobby-card {
  width: 100%; max-width: 360px;
  padding: 32px 26px 24px;
  border-radius: 20px;
  background: linear-gradient(165deg, rgba(88,62,40,.92), rgba(40,27,17,.96));
  border: 1px solid rgba(216,166,87,.22);
  box-shadow: var(--shadow);
}
.brand { text-align: center; margin-bottom: 24px; }
.brand-monogram {
  display: inline-flex; align-items: baseline; gap: 4px;
  padding: 12px 18px 10px; margin-bottom: 14px;
  background: radial-gradient(120% 100% at 50% 0%, rgba(255,224,170,.35), transparent 60%),
    linear-gradient(170deg, #d8a657, #8d5d24);
  border-radius: 12px;
  border: 1px solid rgba(60,32,10,.55);
  box-shadow: inset 0 1px 0 rgba(255,232,180,.5), inset 0 -2px 6px rgba(60,30,8,.35), 0 4px 14px rgba(0,0,0,.4);
}
.m-letter {
  font-family: Georgia, serif; font-size: 26px; font-weight: 700;
  color: #f3dca6;
  text-shadow: 0 1px 0 rgba(255,240,210,.55), 0 -1px 0 rgba(60,28,8,.65), 0 2px 4px rgba(0,0,0,.35);
}
.m-amp { font-size: 20px; color: rgba(80,40,12,.65); font-family: Georgia, serif; }
.brand h1 { margin: 0; font-size: 26px; letter-spacing: 4px; }
.brand .sub { margin: 8px 0 0; font-size: 12px; color: var(--cream-dim); }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; color: var(--cream-dim); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px 14px; font-size: 15px;
  color: var(--cream); font-family: inherit;
  background: rgba(20,13,8,.55);
  border: 1px solid rgba(216,166,87,.2); border-radius: 10px; outline: none;
}
.field input:focus { border-color: rgba(216,166,87,.6); box-shadow: 0 0 0 3px rgba(216,166,87,.12); }
.field input::placeholder { color: #8b7a68; }

.btn-primary {
  width: 100%; padding: 13px; font-size: 15px; font-weight: 600; letter-spacing: 2px;
  color: #2b1d12;
  background: linear-gradient(160deg, #e8be7a, #c99a4e);
  border: none; border-radius: 10px; cursor: pointer;
  box-shadow: 0 6px 18px rgba(201,154,78,.3);
  font-family: inherit;
}
.btn-primary:active { transform: translateY(1px); }
.hint { margin: 16px 0 0; font-size: 11.5px; color: #9c8a76; text-align: center; }

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

/* 顶栏 */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  background: linear-gradient(170deg, #33231a, #241812);
  border-bottom: 1px solid rgba(216,166,87,.15);
}
.back {
  font-size: 28px; line-height: 1; color: var(--cream-dim); cursor: pointer;
  padding: 0 6px;
}
.peer { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.peer-avatar {
  width: 40px; height: 40px; border-radius: 10px; flex: 0 0 auto;
  display: grid; place-items: center;
  font-size: 20px; font-weight: 700; color: #f3dca6;
  background: linear-gradient(160deg, #b07a36, #6a4619);
  box-shadow: inset 0 1px 0 rgba(255,232,180,.4), 0 3px 8px rgba(0,0,0,.4);
}
.peer-info { min-width: 0; }
.peer-name { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peer-status { font-size: 11.5px; color: var(--cream-dim); }
.peer-status.online { color: var(--ok); }

.call-btn {
  width: 40px; height: 40px; border-radius: 50%;
  font-size: 18px; cursor: pointer;
  background: linear-gradient(160deg, #e8be7a, #c99a4e);
  border: none;
  box-shadow: 0 4px 12px rgba(201,154,78,.4);
}
.call-btn:active { transform: scale(.94); }
.call-btn.ringing { animation: ring .8s infinite; }
@keyframes ring { 0%,100% { box-shadow: 0 0 0 0 rgba(201,154,78,.6);} 50% { box-shadow: 0 0 0 8px rgba(201,154,78,0);} }

/* 消息区 */
.msg-list {
  flex: 1; overflow-y: auto;
  padding: 12px 12px 8px;
  scroll-behavior: smooth;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(216,166,87,.05), transparent 60%),
    var(--bg);
}
.day-divider {
  text-align: center; font-size: 11px; color: #8b7a68;
  margin: 10px 0 14px;
}

/* 气泡 */
.msg {
  display: flex; margin-bottom: 12px; align-items: flex-end; gap: 8px;
  animation: popIn .18s ease;
}
@keyframes popIn { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }
.msg.mine { flex-direction: row-reverse; }
.msg .avatar {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 16px; font-weight: 700;
  color: #f3dca6;
  background: linear-gradient(160deg, #b07a36, #6a4619);
}
.msg .body { max-width: 70%; }
.msg .meta { font-size: 10px; color: #8b7a68; margin: 0 2px 3px; }
.msg.mine .meta { text-align: right; }
.msg .bubble {
  padding: 8px 12px; border-radius: 12px;
  font-size: 14.5px; line-height: 1.5; word-break: break-word;
  white-space: pre-wrap;
}
.msg.mine .bubble {
  background: var(--mine-bubble); color: #2b1d12;
  border-bottom-right-radius: 4px;
  box-shadow: 0 3px 8px rgba(0,0,0,.25);
}
.msg.peer .bubble {
  background: var(--peer-bubble); color: var(--cream);
  border-bottom-left-radius: 4px;
  box-shadow: 0 3px 8px rgba(0,0,0,.2);
}
.msg .bubble.image { padding: 3px; }
.msg .bubble.image img {
  display: block; max-width: 200px; max-height: 260px;
  border-radius: 10px; cursor: pointer;
}
.msg .bubble.file {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
}
.msg .bubble.file .f-icon { font-size: 22px; }
.msg .bubble.file .f-name { font-size: 13px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 语音条 */
.voice-msg {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  min-width: 90px;
}
.voice-msg .v-icon { font-size: 14px; transition: transform .1s; }
.voice-msg .v-bar { display: flex; align-items: center; gap: 2px; height: 18px; }
.voice-msg .v-bar i {
  width: 3px; border-radius: 2px;
  background: currentColor;
  transition: height .1s;
}
.voice-msg .v-dur { font-size: 11px; opacity: .8; }

/* 输入区 */
.inputbar {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px calc(env(safe-area-inset-bottom) + 8px);
  background: linear-gradient(170deg, #241812, #1b120b);
  border-top: 1px solid rgba(216,166,87,.12);
}
.input-btn {
  width: 34px; height: 34px; flex: 0 0 auto;
  border-radius: 9px; font-size: 16px; cursor: pointer;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(216,166,87,.15);
  color: var(--cream-dim);
  transition: background .15s;
}
.input-btn:active { background: rgba(216,166,87,.25); }
.text-input {
  flex: 1; min-width: 0;
  padding: 10px 12px; font-size: 14.5px;
  color: var(--cream); font-family: inherit;
  background: rgba(20,13,8,.55);
  border: 1px solid rgba(216,166,87,.2); border-radius: 18px; outline: none;
}
.text-input:focus { border-color: rgba(216,166,87,.5); }
.send-btn {
  padding: 8px 16px; font-size: 14px; font-weight: 600;
  color: #2b1d12;
  background: linear-gradient(160deg, #e8be7a, #c99a4e);
  border: none; border-radius: 16px; cursor: pointer;
  font-family: inherit;
}

/* 按住说话覆盖层 */
.recording {
  position: absolute; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: rgba(20,13,8,.92);
  backdrop-filter: blur(4px);
}
.rec-order { font-size: 13px; color: var(--cream-dim); letter-spacing: 1px; }
.rec-timer {
  font-size: 40px; font-weight: 700; color: var(--gold);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 20px rgba(216,166,87,.4);
}
.recording.cancel { background: rgba(120,40,40,.85); }
.recording.cancel .rec-order { color: #ffd9d9; }

/* 通话覆盖层 */
.call-overlay {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  background: rgba(12,8,5,.85);
  backdrop-filter: blur(8px);
}
.call-card {
  text-align: center; padding: 30px 40px;
  border-radius: 20px;
  background: linear-gradient(165deg, rgba(88,62,40,.95), rgba(40,27,17,.97));
  border: 1px solid rgba(216,166,87,.25);
  box-shadow: var(--shadow);
}
.call-avatar {
  width: 80px; height: 80px; border-radius: 20px; margin: 0 auto 14px;
  display: grid; place-items: center; font-size: 40px; font-weight: 700; color: #f3dca6;
  background: linear-gradient(160deg, #b07a36, #6a4619);
  box-shadow: inset 0 1px 0 rgba(255,232,180,.4), 0 8px 20px rgba(0,0,0,.4);
}
.call-title { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.call-status { font-size: 13px; color: var(--cream-dim); margin-bottom: 22px; }
.call-actions { display: flex; gap: 14px; justify-content: center; }
.call-btn-round {
  width: 58px; height: 58px; border-radius: 50%;
  font-size: 14px; font-weight: 600; border: none; cursor: pointer;
  color: #fff; font-family: inherit;
}
.call-accept { background: linear-gradient(160deg, #8fce7a, #5da44a); box-shadow: 0 6px 16px rgba(93,164,74,.4); }
.call-reject { background: linear-gradient(160deg, #e07a7a, #b04a4a); box-shadow: 0 6px 16px rgba(176,74,74,.4); }
.call-hangup { background: linear-gradient(160deg, #e07a7a, #b04a4a); box-shadow: 0 6px 16px rgba(176,74,74,.4); }

/* 图片预览 */
.img-preview {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(0,0,0,.9);
}
.img-preview img { max-width: 95vw; max-height: 95vh; border-radius: 8px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 16px);
  padding: 10px 18px; border-radius: 10px; font-size: 13px;
  background: rgba(43,29,18,.96);
  border: 1px solid rgba(216,166,87,.28);
  color: var(--cream);
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 60; max-width: 85vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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

/* ===== 设置面板 ===== */
.settings-card { width: min(92vw, 340px); text-align: left; }
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 0; border-bottom: 1px solid rgba(216,166,87,.12);
}
.setting-label { font-size: 14px; font-weight: 600; }
.setting-sub { font-size: 11px; color: var(--cream-dim); margin-top: 3px; }
.setting-actions { display: flex; align-items: center; gap: 8px; }
.avatar-preview {
  width: 44px; height: 44px; border-radius: 11px; object-fit: cover;
  background: linear-gradient(160deg, #b07a36, #6a4619);
}
.btn-mini {
  padding: 7px 14px; font-size: 12.5px; font-weight: 600; border-radius: 8px;
  color: #2b1d12; background: linear-gradient(160deg, #e8be7a, #c99a4e);
  border: none; cursor: pointer; font-family: inherit;
}
.btn-mini.ghost {
  color: var(--cream-dim); background: rgba(255,255,255,.06);
  border: 1px solid rgba(216,166,87,.2);
}

/* 消息头像图片 */
.msg .avatar img, .peer-avatar img, .call-avatar img {
  width: 100%; height: 100%; border-radius: inherit; object-fit: cover;
}

/* 聊天背景（消息区） */
.msg-list.bg-custom {
  background-image: linear-gradient(rgba(20,13,8,.55), rgba(20,13,8,.55)), var(--bg-url);
  background-size: cover; background-position: center;
}

/* ===== 动态 ===== */
.moments {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 12px;
}
.moment-compose {
  background: linear-gradient(165deg, rgba(88,62,40,.6), rgba(40,27,17,.8));
  border: 1px solid rgba(216,166,87,.2); border-radius: 14px; padding: 12px;
}
.moment-text {
  width: 100%; resize: none; font-family: inherit; font-size: 14px; color: var(--cream);
  background: rgba(20,13,8,.55); border: 1px solid rgba(216,166,87,.2);
  border-radius: 10px; padding: 10px; outline: none;
}
.moment-pics { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.moment-pics .pic-x { position: relative; cursor: pointer; }
.moment-pics .pic-x img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; display: block; }
.moment-pics .pic-x::after {
  content: '✕'; position: absolute; top: -6px; right: -6px; width: 18px; height: 18px;
  border-radius: 50%; background: rgba(0,0,0,.7); color: #fff; font-size: 11px;
  display: grid; place-items: center;
}
.moment-actions { display: flex; justify-content: space-between; margin-top: 10px; }
.moment-list { display: flex; flex-direction: column; gap: 12px; }
.moment-card {
  background: linear-gradient(165deg, rgba(88,62,40,.6), rgba(40,27,17,.8));
  border: 1px solid rgba(216,166,87,.18); border-radius: 14px; padding: 12px;
}
.moment-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.moment-head .avatar {
  width: 36px; height: 36px; border-radius: 9px; flex: 0 0 auto;
  display: grid; place-items: center; font-weight: 700; color: #f3dca6;
  background: linear-gradient(160deg, #b07a36, #6a4619);
}
.moment-head .avatar img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.moment-author { font-size: 14px; font-weight: 600; }
.moment-time { font-size: 11px; color: var(--cream-dim); }
.moment-text-body { font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; margin-bottom: 8px; }
.moment-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.moment-grid img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: pointer;
}
.moment-like {
  display: flex; align-items: center; gap: 6px; font-size: 13px;
  color: var(--cream-dim); cursor: pointer; user-select: none;
}
.moment-like.on { color: var(--gold); }
.moment-like.on .heart { animation: heartBeat .3s ease; }
@keyframes heartBeat { 0%,100% { transform: scale(1);} 50% { transform: scale(1.4);} }

@media (max-width: 400px) {
  .msg .bubble.image img { max-width: 160px; }
}
