:root {
  --blue: #185FA5;
  --blue-dark: #0C447C;
  --bg: #F2F4F7;
  --card: #FFFFFF;
  --muted: #6B7280;
  --border: rgba(0, 0, 0, 0.12);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: #1F2937;
  overflow: hidden;
}
.view { height: 100dvh; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
#view-login { align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--card);
  border: 0.5px solid var(--border); border-radius: 16px; padding: 32px 28px;
}
.logo {
  width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 16px;
  background: var(--blue); position: relative;
}
.logo::after {
  content: ""; position: absolute; inset: 14px; border-radius: 50%;
  background: #fff; clip-path: polygon(0 0, 100% 0, 100% 100%, 55% 100%, 30% 72%, 0 72%);
}
.login-card h1 { text-align: center; font-size: 20px; font-weight: 500; color: var(--blue-dark); }
.login-card .sub { text-align: center; font-size: 13px; color: var(--muted); margin: 6px 0 20px; }
input, textarea {
  width: 100%; padding: 11px 12px; font-size: 15px; border-radius: 10px;
  border: 0.5px solid var(--border); background: #FAFBFC; outline: none; font-family: inherit;
}
input:focus, textarea:focus { border-color: var(--blue); background: #fff; }
#btn-enter { width: 100%; margin-top: 14px; }
button.primary {
  padding: 11px 18px; border: none; border-radius: 10px; background: var(--blue);
  color: #fff; font-size: 15px; cursor: pointer; font-family: inherit;
}
button.primary:active { background: var(--blue-dark); }
button.ghost {
  padding: 10px 14px; border: 0.5px solid var(--border); border-radius: 10px;
  background: #fff; color: #374151; font-size: 14px; cursor: pointer; font-family: inherit;
}
button.ghost.danger { color: #B91C1C; }
.mode-row {
  display: flex; justify-content: space-between; align-items: center; margin-top: 18px; font-size: 13px;
}
.mode-label { color: var(--muted); }
.link { border: none; background: none; color: var(--blue); cursor: pointer; font-size: 13px; font-family: inherit; padding: 0; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.6; margin-top: 12px; }

/* ---------- 聊天 ---------- */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--blue); color: #fff;
}
.head-info { display: flex; align-items: center; gap: 10px; }
.room-name { font-size: 16px; font-weight: 500; }
.online { font-size: 12px; opacity: 0.85; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #34D399; flex: none; }
.dot.off { background: #F87171; }
.icon-btn {
  border: none; background: rgba(255,255,255,0.16); color: #fff; width: 36px; height: 36px;
  border-radius: 10px; font-size: 18px; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; flex: none; font-family: inherit;
}

.banner {
  background: #FEF3C7; color: #92400E; font-size: 13px; padding: 8px 16px; text-align: center;
}
.banner.tip { background: #DBEAFE; color: var(--blue-dark); cursor: pointer; }

#msgs { flex: 1; overflow-y: auto; padding: 16px 14px 8px; -webkit-overflow-scrolling: touch; }
.msg { display: flex; gap: 8px; margin-bottom: 14px; align-items: flex-end; }
.msg.mine { flex-direction: row-reverse; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; color: #fff; font-size: 14px;
  display: flex; align-items: center; justify-content: center; flex: none; font-weight: 500;
}
.bubble-wrap { max-width: 74%; display: flex; flex-direction: column; }
.msg.mine .bubble-wrap { align-items: flex-end; }
.meta { font-size: 11px; color: var(--muted); margin: 0 4px 3px; }
.bubble {
  padding: 9px 13px; border-radius: 14px; background: var(--card);
  border: 0.5px solid var(--border); font-size: 15px; line-height: 1.5;
  word-break: break-word; white-space: pre-wrap;
}
.msg.mine .bubble { background: var(--blue); color: #fff; border-color: var(--blue); }
.bubble img { max-width: 100%; border-radius: 10px; display: block; }
.day-divider { text-align: center; font-size: 12px; color: var(--muted); margin: 10px 0 16px; }

.composer {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 10px 12px; padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 0.5px solid var(--border);
}
.img-btn { background: #EEF2F7; color: #475569; }
.img-btn.recording { background: #FEE2E2; color: #B91C1C; }
textarea#input { flex: 1; resize: none; max-height: 110px; border-radius: 12px; }
button.send { flex: none; }

/* ---------- 录音条 ---------- */
.rec {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; background: #FEF2F2; border-top: 0.5px solid #FECACA;
  font-size: 13px; color: #B91C1C;
}
.rec-dot {
  width: 10px; height: 10px; border-radius: 50%; background: #DC2626; flex: none;
  animation: blink 1s infinite;
}
@keyframes blink { 50% { opacity: 0.25; } }
#rec-time { font-weight: 500; min-width: 36px; }
.rec-hint { flex: 1; color: #9F1239; }
.ghost.small { padding: 5px 10px; font-size: 12px; border-radius: 8px; }

/* ---------- 语音播放器 ---------- */
.player {
  display: flex; align-items: center; gap: 10px; min-width: 150px;
  padding: 6px 10px;
}
.pbtn {
  width: 30px; height: 30px; border-radius: 50%; border: none; flex: none;
  background: var(--blue); color: #fff; font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.pbar { flex: 1; height: 4px; border-radius: 2px; background: rgba(24, 95, 165, 0.2); overflow: hidden; }
.pfill { height: 100%; width: 0%; background: var(--blue); border-radius: 2px; }
.pdur { font-size: 12px; color: var(--muted); min-width: 30px; text-align: right; }
.msg.mine .player .pbtn { background: #fff; color: var(--blue); }
.msg.mine .player .pbar { background: rgba(255,255,255,0.3); }
.msg.mine .player .pfill { background: #fff; }
.msg.mine .player .pdur { color: rgba(255,255,255,0.9); }

/* ---------- 弹窗 / 提示 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal-card {
  background: #fff; border-radius: 16px; padding: 24px; width: 100%; max-width: 400px;
  max-height: 86dvh; overflow-y: auto;
}
.modal-card h2 { font-size: 17px; font-weight: 500; margin-bottom: 8px; }
.modal-card label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.modal-btns { display: flex; gap: 10px; margin-top: 14px; }
.modal-btns button { flex: 1; }
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.85); color: #fff; font-size: 13px;
  padding: 9px 16px; border-radius: 10px; z-index: 60; max-width: 80vw; text-align: center;
}
