/* app.css — 爪聊 ClawChat v2 · 移动优先响应式 */
:root {
  --bg: #0b1020;
  --bg2: #101731;
  --panel: rgba(19, 26, 48, 0.72);
  --panel-solid: #141c36;
  --line: rgba(140, 160, 220, 0.16);
  --txt: #e8edfb;
  --dim: #93a0c4;
  --accent: #4fd1c5;
  --accent2: #7c6bff;
  --danger: #ff6b81;
  --ok: #58d68d;
  --bubble-in: #1c2544;
  --bubble-out: linear-gradient(135deg, #2b6f9e, #4a5bd4);
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: radial-gradient(1200px 700px at 20% -10%, #1a2447 0%, var(--bg) 55%) fixed;
  color: var(--txt);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea {
  font: inherit; color: var(--txt);
  background: rgba(10, 15, 32, 0.6);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
::placeholder { color: #5d6a92; }

.glass {
  background: var(--panel);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.08); color: var(--txt);
  transition: transform 0.12s ease, filter 0.15s ease, opacity 0.15s;
  user-select: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font-weight: 600; }
.btn.danger { background: rgba(255, 107, 129, 0.18); color: var(--danger); }
.btn.ghost { background: transparent; color: var(--dim); border: 1px solid var(--line); }
.btn:disabled { opacity: 0.55; cursor: default; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--dim);
  transition: background 0.15s, transform 0.12s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.09); color: var(--txt); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn.danger:hover { color: var(--danger); }
.mini-btn {
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  background: rgba(79, 209, 197, 0.16); color: var(--accent); margin-left: auto;
}
.mini-btn:hover { filter: brightness(1.2); }
.mini {
  font-size: 12px; padding: 5px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}
.mini.ok { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font-weight: 600; }
.mini.no { background: rgba(255, 107, 129, 0.16); color: var(--danger); }
.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ============ 登录 / 注册 ============ */
.auth {
  position: relative; z-index: 2; height: 100%;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.auth-card { width: min(420px, 100%); border-radius: 22px; padding: 28px 26px; animation: rise 0.5s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.brand .logo { width: 54px; height: 54px; filter: drop-shadow(0 6px 18px rgba(79, 209, 197, 0.35)); }
.brand h1 { font-size: 24px; letter-spacing: 1px; }
.brand h1 span { font-size: 14px; color: var(--accent); font-weight: 500; margin-left: 6px; }
.brand .tag { color: var(--dim); font-size: 13px; margin-top: 2px; }
.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tab {
  flex: 1; padding: 10px; border-radius: 10px; color: var(--dim);
  background: rgba(255, 255, 255, 0.05); font-weight: 600;
}
.tab.active { background: linear-gradient(135deg, rgba(79, 209, 197, 0.25), rgba(124, 107, 255, 0.25)); color: #fff; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--dim); }
.form input { padding: 12px 14px; }
.hint { font-size: 12px; color: var(--dim); line-height: 1.6; }
.msg { min-height: 20px; margin-top: 12px; font-size: 13px; color: var(--danger); }
.msg.ok { color: var(--ok); }
.features { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.features span { font-size: 12px; color: var(--accent); background: rgba(79, 209, 197, 0.1); padding: 4px 10px; border-radius: 999px; }

/* ============ 主布局 ============ */
.app { position: relative; z-index: 1; height: 100%; display: flex; padding: 0; }
.sidebar {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  border-radius: 0; border-left: none; border-top: none; border-bottom: none;
}
.main { flex: 1; height: 100%; position: relative; min-width: 0; }
.pane { position: absolute; inset: 0; display: flex; flex-direction: column; background: rgba(11, 16, 32, 0.55); }

/* 侧栏头 */
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
}
.avatar.sm { width: 30px; height: 30px; font-size: 13px; border-radius: 9px; }
.me-info { min-width: 0; }
.me-info b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-info small { color: var(--dim); font-size: 11px; }

/* 搜索 */
.search-box { padding: 12px 14px 6px; }
.search-box input { width: 100%; padding: 10px 14px; }
.search-box.big { display: flex; gap: 8px; padding: 14px; }
.search-box.big input { flex: 1; }
.search-results { padding: 4px 10px 8px; max-height: 40vh; overflow-y: auto; }
.req-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 12px;
}
.req-item:hover { background: rgba(255, 255, 255, 0.05); }
.req-item .who { flex: 1; min-width: 0; }
.req-item .who b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.req-item .who small { color: var(--dim); font-size: 11px; }
.row-btn {
  display: flex; align-items: center; gap: 10px;
  margin: 8px 12px; padding: 11px 12px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.05); font-size: 14px;
}
.row-btn:hover { background: rgba(255, 255, 255, 0.1); }
.row-ico { font-size: 17px; }
.row-txt { flex: 1; text-align: left; }
.list-title {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px 6px; color: var(--dim);
  font-size: 12px; letter-spacing: 1px;
}
.empty { padding: 30px 20px; text-align: center; color: var(--dim); font-size: 13px; }

/* 会话列表 */
.chat-list { list-style: none; overflow-y: auto; flex: 1; padding: 4px 8px 16px; }
.friend-item, .group-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px; border-radius: 14px; cursor: pointer;
  transition: background 0.15s, transform 0.12s;
}
.friend-item:hover, .group-item:hover { background: rgba(255, 255, 255, 0.06); }
.friend-item:active, .group-item:active { transform: scale(0.98); }
.friend-item.active, .group-item.active { background: linear-gradient(135deg, rgba(79, 209, 197, 0.18), rgba(124, 107, 255, 0.18)); }
.friend-item .who, .group-item .who { flex: 1; min-width: 0; }
.friend-item .top, .group-item .top { display: flex; align-items: baseline; gap: 8px; }
.friend-item .top b, .group-item .top b { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-item .top time, .group-item .top time { margin-left: auto; color: var(--dim); font-size: 10.5px; flex: none; }
.friend-item .prev, .group-item .prev {
  color: var(--dim); font-size: 12px; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: #47517a; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px rgba(88, 214, 141, 0.8); }

/* ============ 聊天区 ============ */
.chat-head {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  background: rgba(15, 21, 42, 0.6);
}
.peer { min-width: 0; flex: 1; }
.peer b { display: block; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peer small { color: var(--dim); font-size: 11.5px; }
.messages {
  flex: 1; overflow-y: auto; padding: 18px 14px 10px;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}
.day-div { text-align: center; margin: 8px 0 2px; }
.day-div span {
  font-size: 11px; color: var(--dim);
  background: rgba(255, 255, 255, 0.07); padding: 3px 12px; border-radius: 999px;
}
.msg-row { display: flex; gap: 9px; align-items: flex-end; max-width: 100%; }
.msg-row.out { flex-direction: row-reverse; }
.msg-row .col { display: flex; flex-direction: column; max-width: min(72%, 520px); min-width: 0; }
.msg-row.out .col { align-items: flex-end; }
.sender { font-size: 11px; color: var(--dim); margin: 0 6px 3px; }
.bubble {
  padding: 9px 13px; border-radius: var(--radius);
  background: var(--bubble-in);
  line-height: 1.55; font-size: 14.5px;
  word-break: break-word; white-space: pre-wrap;
  animation: pop 0.18s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
.msg-row.out .bubble { background: var(--bubble-out); color: #fff; border-bottom-right-radius: 5px; }
.msg-row.in .bubble { border-bottom-left-radius: 5px; }
.bubble.media { padding: 6px; overflow: hidden; }
.bubble.media img, .bubble.media video { display: block; max-width: min(260px, 56vw); max-height: 320px; border-radius: 10px; cursor: zoom-in; }
.bubble.media audio { width: min(240px, 55vw); }
.file-card {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, 0.08); padding: 10px 12px; border-radius: 10px;
  min-width: 180px;
}
.file-ico {
  width: 38px; height: 38px; border-radius: 9px; flex: none;
  background: rgba(79, 209, 197, 0.22); display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.file-meta { min-width: 0; }
.file-meta b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 190px; }
.file-meta small { color: var(--dim); font-size: 11px; }
.status-line { font-size: 10.5px; color: var(--dim); margin: 3px 8px 0; display: flex; gap: 6px; align-items: center; }
.status-line.read { color: var(--accent); }
.status-line.failed { color: var(--danger); }
.recall-btn {
  font-size: 10.5px; color: var(--dim); border: 1px solid var(--line);
  padding: 1px 8px; border-radius: 999px;
}
.recall-btn:hover { color: var(--danger); border-color: var(--danger); }
.recalled {
  align-self: center; font-size: 12px; color: var(--dim);
  background: rgba(255, 255, 255, 0.06); padding: 5px 14px; border-radius: 999px;
}

/* 输入区 */
.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: rgba(15, 21, 42, 0.6);
}
.composer textarea {
  flex: 1; resize: none; padding: 11px 14px;
  max-height: 132px; line-height: 1.5; font-size: 15px;
}
.btn.send { padding: 11px 20px; }

/* 新的朋友 / 群面板 */
.friends-body { overflow-y: auto; padding-bottom: 24px; }
.req-list { list-style: none; padding: 2px 12px; display: flex; flex-direction: column; gap: 2px; }
.nf-results { padding: 2px 12px; }

/* 空态 */
.welcome { align-items: center; justify-content: center; text-align: center; padding: 22px; gap: 8px; background: transparent; }
.welcome .logo.big { width: 92px; height: 92px; filter: drop-shadow(0 12px 30px rgba(79, 209, 197, 0.3)); animation: float 5s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-12px) rotate(2deg); } }
.welcome h2 { font-size: 22px; letter-spacing: 1px; }
.welcome p { color: var(--dim); font-size: 14px; line-height: 1.8; max-width: 320px; }
.welcome b { color: var(--accent); }
.dim { color: var(--dim); }

/* ============ 弹窗 ============ */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(5, 8, 18, 0.66);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.modal-card {
  width: min(400px, 100%); border-radius: 18px; padding: 22px;
  display: flex; flex-direction: column; gap: 12px;
  max-height: 82vh; overflow-y: auto;
  animation: rise 0.25s ease;
}
.modal-card h3 { font-size: 17px; }
.modal-card hr { border: none; border-top: 1px solid var(--line); margin: 6px 0; }
.kv { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--dim); padding: 4px 0; }
.kv b { color: var(--txt); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--dim); }
.field input { padding: 11px 13px; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.row-btns .btn { flex: 1; min-width: 110px; }
.group-pick {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 200px; overflow-y: auto;
}
.pick-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 10px; cursor: pointer; font-size: 14px;
}
.pick-item:hover { background: rgba(255, 255, 255, 0.06); }
.pick-item input { accent-color: var(--accent); width: 17px; height: 17px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%);
  z-index: 99; padding: 11px 22px; border-radius: 999px;
  background: rgba(20, 28, 54, 0.95); color: var(--txt);
  border: 1px solid var(--line); box-shadow: var(--shadow);
  font-size: 13.5px; animation: rise 0.2s ease;
  max-width: 84vw; text-align: center;
}

/* 图片全屏查看 */
#viewer {
  position: fixed; inset: 0; z-index: 60; background: rgba(4, 6, 14, 0.9);
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
#viewer img { max-width: 94vw; max-height: 92vh; border-radius: 10px; }

.only-mobile { display: none; }

/* ============ 响应式：桌面 ============ */
@media (min-width: 780px) {
  .app { padding: 16px; gap: 16px; }
  .sidebar { width: 320px; flex: none; border-radius: 20px; border: 1px solid var(--line); overflow: hidden; }
  .main { border-radius: 20px; overflow: hidden; border: 1px solid var(--line); background: rgba(13, 19, 38, 0.5); }
  .pane { background: transparent; }
  .bubble .status-line, .msg-row .status-line { opacity: 0.85; }
}

/* ============ 响应式：手机 ============ */
@media (max-width: 779px) {
  .only-mobile { display: inline-flex; }
  .main { display: none; }
  body.chat-open .main { display: block; }
  body.chat-open .sidebar { display: none; }
  body:not(.chat-open) .main { display: none; }
  .messages { padding: 14px 10px 8px; }
  .msg-row .col { max-width: 78%; }
  .btn.send { padding: 11px 14px; }
  .icon-btn { width: 34px; height: 34px; }
}

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(140, 160, 220, 0.25); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; scroll-behavior: auto !important; }
}

/* 切换版本入口（小而不碍事） */
.ver-switch{position:fixed;right:10px;bottom:8px;z-index:60;font-size:11px;line-height:1;
  color:#9db4dd;text-decoration:none;opacity:.4;padding:5px 8px;border-radius:8px;
  background:rgba(8,12,26,.35);backdrop-filter:blur(4px)}
.ver-switch:hover{opacity:.95}
