/* MyXin Link 手机端 —— 移动优先，微信式布局 */
:root {
  --bg: #f7f7f9;
  --card: #ffffff;
  --line: #ececf2;
  --text: #16161a;
  --sub: #8a8a92;
  --green: #07c160;
  --green-dark: #06ad56;
  --purple: #7c5cff;
  --bubble-me: #95ec69;
  --bubble-you: #ffffff;
  --radius: 10px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, "HarmonyOS Sans", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  overscroll-behavior: none;
}
button { font-family: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

#app { height: 100dvh; display: flex; flex-direction: column; }
.page { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.page[hidden] { display: none; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.me { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.avatar {
  width: 38px; height: 38px; border-radius: 9px; flex: none;
  background: var(--purple); color: #fff;
  display: grid; place-items: center; font-weight: 600;
}
.me-text { display: flex; flex-direction: column; min-width: 0; }
.me-text b { font-size: 16px; }
.me-text small { color: var(--sub); font-size: 11px; letter-spacing: .3px; }
.top-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 38px; height: 38px; border: 0; border-radius: 9px;
  background: transparent; color: #333; display: grid; place-items: center;
}
.icon-btn:active { background: #f0f0f4; }

.strip {
  font-size: 12px; color: var(--sub); padding: 6px 14px;
  background: #fbfbfd; border-bottom: 1px solid var(--line);
}
.strip.warn { color: #c2410c; background: #fff7ed; }

/* ---------------- 列表 ---------------- */
.list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 8px; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--card);
  border-bottom: 1px solid var(--line);
}
.row:active { background: #f6f6fa; }
.row .avatar { width: 44px; height: 44px; border-radius: 10px; font-size: 16px; }
.row-main { flex: 1; min-width: 0; }
.row-top { display: flex; align-items: baseline; gap: 8px; }
.row-top b { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-top time { margin-left: auto; font-size: 11px; color: var(--sub); flex: none; }
.row-sub {
  margin-top: 2px; font-size: 13px; color: var(--sub);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.unread {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: #fa5151; color: #fff; font-size: 11px; line-height: 18px;
  text-align: center; flex: none;
}
.empty { padding: 60px 24px; text-align: center; color: var(--sub); font-size: 13px; line-height: 2; }
.empty b { display: block; font-size: 30px; margin-bottom: 8px; }

/* ---------------- 底部 tab ---------------- */
.tabbar {
  display: flex; background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabbar button {
  flex: 1; border: 0; background: transparent; color: var(--sub);
  font-size: 12px; padding: 9px 0 10px; position: relative;
}
.tabbar button.on { color: var(--green); font-weight: 600; }
.badge {
  position: absolute; top: 4px; left: 50%; margin-left: 6px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: #fa5151; color: #fff; font-size: 10px; line-height: 16px; font-style: normal;
}

/* ---------------- 聊天 ---------------- */
.chat-head { gap: 4px; }
.chat-title { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; }
.chat-title b { font-size: 15px; }
.chat-title small { font-size: 11px; color: var(--sub); }
.chat-head .back { margin-left: -8px; }

.msgs {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 14px 12px 6px; display: flex; flex-direction: column; gap: 10px;
  background: #f2f2f5;
}
.msg { display: flex; gap: 8px; align-items: flex-start; }
.msg.me { flex-direction: row-reverse; }
.msg .avatar { width: 34px; height: 34px; border-radius: 8px; font-size: 13px; }
.bubble {
  max-width: 76vw; padding: 9px 11px; border-radius: 8px;
  background: var(--bubble-you); font-size: 15px; word-break: break-word;
  white-space: pre-wrap; box-shadow: 0 1px 0 rgba(0,0,0,.04);
}
.msg.me .bubble { background: var(--bubble-me); }
.msg .meta { font-size: 10px; color: #a0a0a8; align-self: flex-end; margin-bottom: 2px; }
.bubble img { display: block; max-width: 60vw; max-height: 40vh; border-radius: 6px; }
.file-card { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.file-ico {
  width: 38px; height: 44px; border-radius: 5px; flex: none;
  background: #eef0ff; color: #4f46e5; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; letter-spacing: .5px;
}
.file-info { min-width: 0; }
.file-info b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 44vw; }
.file-info small { color: var(--sub); font-size: 11px; }
.progress { height: 3px; border-radius: 2px; background: rgba(0,0,0,.08); margin-top: 6px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--green); width: 0; }
.msg-sys { align-self: center; font-size: 11.5px; color: #8a8a92; background: rgba(0,0,0,.045); padding: 4px 10px; border-radius: 10px; }

.composer {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 8px 10px calc(8px + var(--safe-b));
  background: var(--card); border-top: 1px solid var(--line);
}
.tool {
  width: 34px; height: 34px; border: 0; background: transparent; color: #444;
  display: grid; place-items: center; flex: none;
}
.composer textarea {
  flex: 1; min-height: 34px; max-height: 120px; resize: none;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; font: inherit; background: #fbfbfd; outline: none;
}
.composer textarea:focus { border-color: var(--green); background: #fff; }
.send {
  border: 0; background: var(--green); color: #fff; border-radius: 8px;
  padding: 0 16px; height: 34px; font-size: 14px; font-weight: 600; flex: none;
}
.send:disabled { opacity: .45; }
.send:active { background: var(--green-dark); }

/* ---------------- 弹层 ---------------- */
.sheet-mask {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0,0,0,.35); display: flex; align-items: flex-end;
}
.sheet-mask[hidden] { display: none; }
.sheet {
  width: 100%; max-height: 88dvh; overflow-y: auto;
  background: var(--card); border-radius: 14px 14px 0 0;
  padding: 16px 16px calc(16px + var(--safe-b));
  animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(14px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet h3 { margin: 0 0 4px; font-size: 17px; }
.sheet .hint { color: var(--sub); font-size: 12px; margin: 4px 0 12px; line-height: 1.6; }
.sheet .field { margin-bottom: 12px; }
.sheet label { display: block; font-size: 12px; color: var(--sub); margin-bottom: 5px; }
.sheet input[type=text], .sheet textarea, .sheet select {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 10px; font: inherit; background: #fbfbfd; outline: none;
}
.sheet textarea { min-height: 68px; resize: vertical; word-break: break-all; font-size: 13px; }
.sheet .btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--line); background: #fff; color: #333;
  border-radius: 8px; padding: 9px 14px; font-size: 14px;
}
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.btn.ghost { color: var(--sub); }
.btn.danger { color: #d4483f; border-color: #f3d6d3; }
.btn:active { filter: brightness(.96); }
.sheet .code {
  font: 11px/1.5 ui-monospace, Consolas, monospace;
  background: #f5f5fa; border-radius: 8px; padding: 9px 10px;
  word-break: break-all; color: #444; max-height: 88px; overflow: auto;
}
.qr-wrap { display: grid; place-items: center; padding: 10px 0; }
.qr-wrap canvas { width: 232px; height: 232px; image-rendering: pixelated; background: #fff; }
.me-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.me-head .avatar { width: 52px; height: 52px; border-radius: 12px; font-size: 18px; }
.me-head .nm { font-size: 17px; font-weight: 600; }
.me-head .idd { font-size: 11.5px; color: var(--sub); letter-spacing: .4px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--sub); }
.kv span:last-child { text-align: right; word-break: break-all; }
.safety { font: 12px/1.9 ui-monospace, Consolas, monospace; white-space: pre; background: #f5f5fa; border-radius: 8px; padding: 8px 10px; }

/* ---------------- Toast ---------------- */
.toasts { position: fixed; left: 0; right: 0; top: calc(env(safe-area-inset-top, 0px) + 54px); z-index: 40; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: rgba(28,28,32,.9); color: #fff; font-size: 13px;
  padding: 8px 14px; border-radius: 10px; max-width: 84vw;
  animation: fade .2s ease-out;
}
.toast.ok { background: rgba(7,193,96,.94); }
.toast.error { background: rgba(214,68,60,.94); }
@keyframes fade { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
