/* =====================================================
   密语 MiYu — 样式（浅色专业风 · 移动端适配）
   无内联样式，配合 CSP style-src 'self'
   ===================================================== */
:root {
  --bg: #eef2f7;
  --card: #ffffff;
  --line: #dbe3ee;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-deep: #1d4ed8;
  --primary-soft: #dbeafe;
  --burn: #dc2626;
  --burn-bg: #fef2f2;
  --burn-line: #fecaca;
  --ok: #16a34a;
  --ok-bg: #e8f7ee;
  --ok-line: #bfe6cd;
  --shadow: 0 10px 30px rgba(15, 23, 42, .08);
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }

/* ---------- 顶部提示条 ---------- */
.banner {
  background: #fef3c7;
  color: #92400e;
  border-bottom: 1px solid #fcd34d;
  padding: 10px 16px;
  font-size: 13.5px;
  text-align: center;
}
.banner b { font-weight: 700; }

/* ---------- 登录/注册 ---------- */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(1200px 500px at 15% -10%, #dbeafe 0%, transparent 60%),
    radial-gradient(1000px 500px at 110% 10%, #e0e7ff 0%, transparent 55%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px 28px 24px;
}

.brand { text-align: center; margin-bottom: 22px; }
.brand-lock {
  width: 46px; height: 46px;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 14px;
  padding: 10px;
  margin-bottom: 10px;
}
.brand h1 { font-size: 28px; letter-spacing: 2px; }
.tagline { color: var(--muted); font-size: 13px; margin-top: 4px; letter-spacing: 1px; }

.tabs {
  display: flex;
  background: #f1f5f9;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 20px;
}
.tab {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 9px 0;
  border-radius: 9px;
  font-size: 15px;
  color: var(--muted);
  font-weight: 600;
  transition: all .15s;
}
.tab.active { background: #fff; color: var(--primary); box-shadow: 0 1px 4px rgba(15,23,42,.12); }

.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
  background: #f8fafc;
  transition: border-color .15s;
}
.field input:focus { outline: none; border-color: var(--primary); background: #fff; }

.error {
  background: var(--burn-bg);
  border: 1px solid var(--burn-line);
  color: var(--burn);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  margin-bottom: 12px;
}

.auth-note {
  background: var(--ok-bg, #e8f7ee);
  border: 1px solid var(--ok-line, #bfe6cd);
  color: var(--ok, #1a7f37);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  margin-bottom: 12px;
}

.primary-btn {
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 12px 0;
  transition: background .15s;
}
.primary-btn:hover { background: var(--primary-deep); }
.primary-btn:disabled { background: #93c5fd; cursor: wait; }

.busy { text-align: center; color: var(--muted); font-size: 13px; margin-top: 10px; }

.promise {
  list-style: none;
  margin-top: 22px;
  border-top: 1px dashed var(--line);
  padding-top: 16px;
  display: grid;
  gap: 8px;
}
.promise li { font-size: 13px; color: var(--muted); }
.promise b { color: var(--text); }

.auth-foot {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  line-height: 1.8;
  word-break: break-all;
}
.auth-foot .k { color: var(--text); font-weight: 600; }

/* ---------- 聊天主界面布局 ---------- */
.chat-screen {
  height: 100dvh;
  display: flex;
  overflow: hidden;
}

.sidebar {
  width: 300px;
  min-width: 300px;
  background: var(--card);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.me-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px;
  border-bottom: 1px solid var(--line);
}
.me-info { flex: 1; min-width: 0; }
.me-info b { display: block; font-size: 15px; }
.me-status { font-size: 12px; color: var(--muted); }
.me-status.on { color: var(--ok); }
.me-actions { display: flex; gap: 6px; }

.icon-btn {
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--muted);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12.5px;
  transition: all .15s;
}
.icon-btn:hover { color: var(--text); border-color: #c3cede; }
.icon-btn.danger:hover { color: var(--burn); border-color: var(--burn-line); background: var(--burn-bg); }

.avatar.h0 { background: hsl(0 60% 45%); }
.avatar.h1 { background: hsl(25 60% 45%); }
.avatar.h2 { background: hsl(50 55% 42%); }
.avatar.h3 { background: hsl(75 45% 40%); }
.avatar.h4 { background: hsl(100 40% 40%); }
.avatar.h5 { background: hsl(125 40% 40%); }
.avatar.h6 { background: hsl(150 40% 40%); }
.avatar.h7 { background: hsl(175 45% 38%); }
.avatar.h8 { background: hsl(200 55% 45%); }
.avatar.h9 { background: hsl(225 55% 48%); }
.avatar.h10 { background: hsl(255 50% 50%); }
.avatar.h11 { background: hsl(285 45% 48%); }
.avatar {
  width: 38px; height: 38px;
  min-width: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  background: var(--primary);
}

.add-contact {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.add-contact input {
  flex: 1;
  min-width: 0;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 14px;
  background: #f8fafc;
}
.add-contact input:focus { outline: none; border-color: var(--primary); background: #fff; }
.add-btn {
  border: 0;
  background: var(--primary);
  color: #fff;
  border-radius: 9px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 600;
}
.add-btn:hover { background: var(--primary-deep); }

.contact-list { flex: 1; overflow-y: auto; padding: 8px; }

.contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: background .12s;
  position: relative;
}
.contact-item:hover { background: #f1f5f9; }
.contact-item.active { background: var(--primary-soft); }
.contact-item .avatar { width: 34px; height: 34px; min-width: 34px; font-size: 13px; }
.contact-body { flex: 1; min-width: 0; }
.contact-name { font-weight: 600; font-size: 14.5px; display: flex; align-items: center; gap: 6px; }
.contact-preview {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.presence-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  display: inline-block;
  flex: none;
}
.presence-dot.online { background: var(--ok); box-shadow: 0 0 0 3px rgba(22,163,74,.15); }

.unread-badge {
  background: var(--burn);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 10px 14px;
  text-align: center;
}
.lock-badge {
  font-size: 12px;
  color: var(--ok);
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 999px;
  padding: 4px 12px;
}

/* ---------- 聊天区 ---------- */
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #f6f8fb; }

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.back-btn {
  display: none;
  border: 0;
  background: transparent;
  font-size: 26px;
  color: var(--muted);
  padding: 0 6px;
  line-height: 1;
}
.peer-info { flex: 1; min-width: 0; }
.peer-info b { display: block; font-size: 16px; }
.peer-presence { font-size: 12px; color: var(--muted); }
.peer-presence.online { color: var(--ok); }

.safety-btn {
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 9px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.safety-btn:hover { color: var(--text); }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-hint {
  margin: auto;
  text-align: center;
  color: var(--muted);
}
.empty-icon { font-size: 42px; margin-bottom: 8px; }
.empty-sub { font-size: 12.5px; margin-top: 4px; opacity: .8; }

.day-divider {
  align-self: center;
  font-size: 12px;
  color: var(--muted);
  background: #e8edf4;
  border-radius: 999px;
  padding: 3px 12px;
  margin: 6px 0;
}

.msg-row { display: flex; gap: 8px; max-width: 100%; }
.msg-row.out { flex-direction: row-reverse; }
.msg-row .avatar { width: 30px; height: 30px; min-width: 30px; font-size: 12px; align-self: flex-end; }

.bubble-wrap { max-width: min(72%, 520px); display: flex; flex-direction: column; }
.msg-row.out .bubble-wrap { align-items: flex-end; }

.bubble {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px 14px 14px 4px;
  padding: 9px 12px;
  font-size: 14.5px;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
  position: relative;
}
.msg-row.out .bubble {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
}

/* 焚毁类消息 */
.bubble.burn {
  background: var(--burn-bg);
  border: 1.5px solid var(--burn-line);
  color: var(--text);
}
.bubble.burn::before {
  content: "🔥 阅后即焚";
  display: block;
  font-size: 11px;
  color: var(--burn);
  font-weight: 700;
  margin-bottom: 3px;
  letter-spacing: .5px;
}
.bubble.burn.timer-mode::before { content: "⏱ 定时焚毁"; }

.burn-countdown {
  position: absolute;
  top: -10px;
  right: -6px;
  background: var(--burn);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 8px;
  box-shadow: 0 2px 6px rgba(220,38,38,.35);
  font-variant-numeric: tabular-nums;
}

.burn-now-btn {
  margin-top: 5px;
  border: 1px solid var(--burn-line);
  background: #fff;
  color: var(--burn);
  font-size: 12px;
  border-radius: 8px;
  padding: 3px 10px;
}
.burn-now-btn:hover { background: var(--burn); color: #fff; }

.msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
  padding: 0 2px;
}
.msg-row.out .msg-meta { flex-direction: row-reverse; }
.msg-meta .burned-tag { color: var(--burn); font-weight: 600; }
.msg-meta .recalled-tag { color: var(--muted); }

.msg-file img.msg-img {
  max-width: 240px;
  max-height: 240px;
  border-radius: 8px;
  display: block;
  cursor: pointer;
  border: 1px solid rgba(0,0,0,.06);
}
.msg-file a.file-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 13.5px;
}
.msg-row.out .msg-file a.file-link { color: #fff; }

/* ---------- 输入区 ---------- */
.composer {
  border-top: 1px solid var(--line);
  background: var(--card);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
}

.composer-modes {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--muted);
}
.mode { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; }
.mode input { accent-color: var(--primary); }
.mode.burn input { accent-color: var(--burn); }
.mode.burn span { color: var(--burn); }
.mode input:not(:checked) ~ span { color: var(--muted); }
.flex-spacer { flex: 1; }

.seconds-input {
  width: 52px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 3px 6px;
  font-size: 13px;
  text-align: center;
}
.unit { font-size: 12px; }

.composer-row { display: flex; gap: 10px; align-items: flex-end; }

#msg-input {
  flex: 1;
  field-sizing: content;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14.5px;
  resize: none;
  max-height: 120px;
  background: #f8fafc;
  line-height: 1.45;
}
#msg-input:focus { outline: none; border-color: var(--primary); background: #fff; }

.send-btn {
  border: 0;
  background: var(--primary);
  color: #fff;
  border-radius: 12px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 700;
  min-height: 42px;
}
.send-btn:hover { background: var(--primary-deep); }
.send-btn:disabled { background: #93c5fd; cursor: wait; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.modal h3 { margin-bottom: 12px; font-size: 17px; }
.modal .modal-body { font-size: 14px; color: var(--text); margin-bottom: 18px; }
.modal .primary-btn { width: auto; padding: 10px 28px; letter-spacing: 1px; }

.safety-digits {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 17px;
  letter-spacing: 1px;
  background: #f8fafc;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  margin: 10px 0;
  word-spacing: 4px;
  user-select: all;
}
.modal-note { font-size: 12.5px; color: var(--muted); line-height: 1.7; }

/* ---------- 移动端适配 ---------- */
@media (max-width: 760px) {
  .sidebar {
    position: absolute;
    inset: 0;
    z-index: 20;
    width: 100%;
    min-width: 0;
    transform: translateX(0);
    transition: transform .2s ease;
  }
  .chat-screen.show-chat .sidebar { transform: translateX(-100%); }
  .back-btn { display: block; }
  .bubble-wrap { max-width: 82%; }
  .msg-file img.msg-img { max-width: 200px; max-height: 200px; }
  .messages { padding: 14px 10px 8px; }
  .safety-btn { padding: 6px 8px; font-size: 12px; }
}

@media (min-width: 761px) {
  .sidebar { position: relative; }
}

/* 滚动条 */
.tombstone { opacity: .75; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
::-webkit-scrollbar-track { background: transparent; }
