/* napcat-web 移动端样式：仅用 flex + 常规属性，兼容微信 X5/WKWebView 内核 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
:root { --app-h: 100vh; --green: #07c160; --blue: #1296db; }
body {
  position: fixed; left: 0; top: 0; width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  font-size: 15px; color: #191919; background: #ededed;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.view { height: var(--app-h); display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; }

/* ---------- 登录 ---------- */
#view-login {
  -webkit-align-items: center; align-items: center;
  -webkit-justify-content: center; justify-content: center;
  background: -webkit-linear-gradient(top, #1296db, #0a6eb0);
  background: linear-gradient(180deg, #1296db, #0a6eb0);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 360px;
  background: #fff; border-radius: 14px; padding: 28px 22px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .18);
  text-align: center;
}
.login-logo {
  width: 56px; height: 56px; line-height: 56px; margin: 0 auto 10px;
  border-radius: 14px; background: var(--blue); color: #fff;
  font-size: 30px; font-weight: 700;
}
.login-card h1 { font-size: 19px; margin-bottom: 4px; }
.login-card .sub { font-size: 12px; color: #999; margin-bottom: 20px; }
.login-card input {
  width: 100%; padding: 11px 12px; font-size: 16px;
  border: 1px solid #ddd; border-radius: 8px; margin-bottom: 12px; outline: none;
  background: #f7f7f7;
}
.login-card input:focus { border-color: var(--blue); background: #fff; }
#login-btn {
  width: 100%; padding: 12px; font-size: 16px; color: #fff;
  background: var(--blue); border: none; border-radius: 8px; margin-top: 2px;
}
#login-btn:active { opacity: .85; }
.err { color: #e64340; font-size: 13px; min-height: 18px; margin-top: 10px; }
.state { color: #aaa; font-size: 12px; margin-top: 4px; }

/* ---------- 主界面 ---------- */
#view-main { position: relative; background: #ededed; }
@media (min-width: 700px) {
  #view-main { max-width: 480px; margin: 0 auto; box-shadow: 0 0 24px rgba(0, 0, 0, .15); }
}
.page {
  position: absolute; left: 0; top: 0; right: 0; bottom: 0;
  display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column;
  background: #ededed;
}
.chat-page {
  background: #ededed;
  -webkit-transform: translateX(100%); transform: translateX(100%);
  -webkit-transition: -webkit-transform .2s ease-out; transition: transform .2s ease-out;
  z-index: 2;
}
.chat-page.show { -webkit-transform: translateX(0); transform: translateX(0); }

.topbar {
  -webkit-flex: none; flex: none;
  height: 46px; display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center;
  background: #f7f7f7; border-bottom: 1px solid #dcdcdc; padding: 0 10px;
  padding-top: env(safe-area-inset-top);
}
.tb-title { font-size: 17px; font-weight: 600; -webkit-flex: 1; flex: 1; }
.tb-title.center { text-align: center; font-size: 16px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tb-btn {
  border: none; background: none; color: #333; font-size: 14px; padding: 6px 8px;
}
.tb-btn.ghost { color: #666; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; }
.dot.on { background: var(--green); }
.dot.off { background: #fa5151; }

/* 会话列表 */
.tabs { -webkit-flex: none; flex: none; display: -webkit-flex; display: flex; background: #fff; border-bottom: 1px solid #e5e5e5; }
.tab { -webkit-flex: 1; flex: 1; padding: 10px 0; text-align: center; color: #666; font-size: 15px; border: none; background: none; }
.tab.active { color: var(--blue); font-weight: 600; box-shadow: inset 0 -2px 0 var(--blue); }
.search { -webkit-flex: none; flex: none; padding: 8px 10px; background: #fff; }
.search input { width: 100%; padding: 8px 12px; font-size: 14px; border: none; border-radius: 8px; background: #f0f0f0; outline: none; }
.chat-list { -webkit-flex: 1; flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; list-style: none; }
.chat-list li { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; padding: 10px 12px; background: #fff; border-bottom: 1px solid #f0f0f0; }
.chat-list li:active { background: #f5f5f5; }
.chat-list li.empty { -webkit-justify-content: center; justify-content: center; color: #aaa; font-size: 13px; padding: 30px 0; background: transparent; border: none; }
.ava { width: 44px; height: 44px; border-radius: 6px; background: #cfd8e3; -webkit-flex: none; flex: none; }
.chat-list .mid { -webkit-flex: 1; flex: 1; min-width: 0; margin-left: 10px; }
.chat-list .row { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; }
.chat-list .row + .row { margin-top: 3px; }
.chat-list .name { font-size: 16px; -webkit-flex: 1; flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-list .time { font-size: 12px; color: #b2b2b2; margin-left: 8px; }
.chat-list .preview { -webkit-flex: 1; flex: 1; font-size: 13px; color: #999; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.badge { -webkit-flex: none; flex: none; min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px; border-radius: 9px; background: #fa5151; color: #fff; font-size: 11px; text-align: center; }

/* 聊天页 */
.banner { -webkit-flex: none; flex: none; background: #ffecec; color: #c0392b; font-size: 12px; text-align: center; padding: 5px 8px; }
#msgs { -webkit-flex: 1; flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 0 10px; }
.more { display: block; margin: 10px auto 2px; padding: 6px 16px; font-size: 13px; color: #666; background: #fff; border: 1px solid #ddd; border-radius: 14px; }
.loading { text-align: center; color: #aaa; font-size: 13px; padding: 20px 0; }
.day { text-align: center; font-size: 12px; color: #9a9a9a; margin: 12px 0 6px; }

.msg { display: -webkit-flex; display: flex; -webkit-align-items: flex-start; align-items: flex-start; margin: 9px 10px; }
.msg .ava { width: 38px; height: 38px; border-radius: 5px; }
.msg.other .ava { margin-right: 9px; }
.msg.self { -webkit-flex-direction: row-reverse; flex-direction: row-reverse; }
.msg.self .ava { margin-left: 9px; }
.msg .col { max-width: 72%; display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; min-width: 0; }
.msg.self .col { -webkit-align-items: flex-end; align-items: flex-end; }
.sender { font-size: 12px; color: #888; margin: 0 6px 2px; }
.bubble {
  background: #fff; border-radius: 6px; padding: 9px 11px;
  line-height: 1.45; word-break: break-word; -webkit-user-select: text; user-select: text;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .04); font-size: 15px;
}
.msg.self .bubble { background: #95ec69; }
.msg.sending .bubble { opacity: .55; }
.msg.failed .bubble { outline: 1px solid #e64340; }
.msg.failed .bubble::after { content: "（发送失败，点按重试）"; display: block; color: #e64340; font-size: 12px; margin-top: 3px; }
.msg-img { max-width: 180px; max-height: 240px; border-radius: 4px; display: block; }
.at { color: var(--blue); }
.reply-quote { font-size: 12px; color: #888; border-left: 2px solid #ccc; padding-left: 6px; margin-bottom: 4px; }
.file-link { color: var(--blue); text-decoration: none; }

/* 输入区 */
.composer {
  -webkit-flex: none; flex: none; display: -webkit-flex; display: flex;
  -webkit-align-items: flex-end; align-items: flex-end;
  padding: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom));
  background: #f7f7f7; border-top: 1px solid #dcdcdc;
}
.composer textarea {
  -webkit-flex: 1; flex: 1; resize: none; border: none; outline: none;
  border-radius: 6px; background: #fff; padding: 9px 10px;
  font-size: 16px; line-height: 1.35; max-height: 90px; font-family: inherit;
}
#btn-send {
  -webkit-flex: none; flex: none; margin-left: 8px; border: none; border-radius: 6px;
  background: var(--green); color: #fff; font-size: 15px; padding: 10px 15px;
}
#btn-send:active { opacity: .8; }

/* 表情文字 / 合并转发 */
.qface { color: #e69120; }
.fwd-link { color: #576b95; }
.fwd-viewer {
  display: none; position: fixed; left: 0; top: 0; right: 0; bottom: 0; z-index: 100;
  background: rgba(0, 0, 0, .5);
}
.fwd-viewer.show { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center; }
.fwd-panel { background: #fff; border-radius: 10px; width: 92%; max-width: 420px; max-height: 78%; display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; overflow: hidden; }
.fwd-head { -webkit-flex: none; flex: none; padding: 12px 44px 12px 14px; font-weight: 600; border-bottom: 1px solid #eee; position: relative; }
.fwd-close { position: absolute; right: 8px; top: 6px; border: none; background: none; font-size: 22px; color: #999; padding: 4px 8px; }
.fwd-body { -webkit-flex: 1; flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 14px 10px; }
.fwd-item { padding: 9px 0; border-bottom: 1px solid #f2f2f2; }
.fwd-item:last-child { border-bottom: none; }
.fwd-sender { font-size: 13px; color: #576b95; font-weight: 600; }
.fwd-time { color: #b2b2b2; font-weight: 400; font-size: 11px; margin-left: 6px; }
.fwd-text { font-size: 15px; margin-top: 2px; line-height: 1.45; word-break: break-word; }
.fwd-img { max-width: 130px; border-radius: 4px; display: block; margin: 4px 0; }

/* 图片查看器 */
.img-viewer {
  display: none; position: fixed; left: 0; top: 0; right: 0; bottom: 0; z-index: 100;
  background: rgba(0, 0, 0, .92); overflow: auto; -webkit-overflow-scrolling: touch;
}
.img-viewer.show { display: -webkit-flex; display: flex; }
.img-viewer img { margin: auto; max-width: 100%; max-height: 100%; }
.img-viewer img.orig { max-width: none; max-height: none; }
.iv-close {
  position: fixed; top: calc(10px + env(safe-area-inset-top)); right: 12px; z-index: 101;
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: rgba(255, 255, 255, .18); color: #fff; font-size: 22px; line-height: 34px;
}

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: 90px; -webkit-transform: translateX(-50%); transform: translateX(-50%);
  background: rgba(0, 0, 0, .75); color: #fff; font-size: 13px;
  padding: 8px 14px; border-radius: 8px; z-index: 99; max-width: 80%;
  -webkit-transition: opacity .3s; transition: opacity .3s;
}
