/* H5转码 —— 微信聊天式界面（手机 / 电脑自适应） */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #ededed;
  --green: #95ec69;
  --line: #dcdcdc;
  --txt: #191919;
  --sub: #888;
}

html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #43434b;              /* 电脑端外围底色 */
  color: var(--txt);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
}
@media (min-width: 800px) {
  .app { height: 92dvh; margin-top: 4dvh; border-radius: 14px; overflow: hidden;
         box-shadow: 0 12px 48px rgba(0,0,0,.35); }
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: #f7f7f7; border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.brand { font-size: 17px; font-weight: 600; }
.top-right { display: flex; align-items: center; gap: 10px; font-size: 13px; white-space: nowrap; }
.balance b { color: #fa5151; }
.uname { color: var(--sub); }
.mini-link { color: #576b95; text-decoration: none; }
/* 小屏：挤不下时先隐藏昵称，保住「余额 / 清空记录 / 退出」 */
@media (max-width: 400px) {
  .topbar { padding: 11px 12px; }
  .top-right { gap: 8px; font-size: 12.5px; }
  .uname { display: none; }
}

/* ---------- 公告 ---------- */
.notice {
  flex-shrink: 0; padding: 7px 16px; font-size: 12.5px; color: #b8860b;
  background: #fff8e1; border-bottom: 1px solid #f5e6b8;
  white-space: pre-wrap;
}

/* ---------- 消息区 ---------- */
.chat { flex: 1; overflow-y: auto; padding: 16px 12px 8px; -webkit-overflow-scrolling: touch; }

.msg-row { display: flex; margin-bottom: 14px; align-items: flex-start; }
.msg-row.me { justify-content: flex-end; }
.msg-row.bot { justify-content: flex-start; }

.avatar {
  width: 38px; height: 38px; border-radius: 6px; flex-shrink: 0;
  background: #1e6fff; color: #fff; font-size: 15px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.msg-row.me .avatar { background: #c0c0c0; margin-left: 10px; }
.msg-row.bot .avatar { margin-right: 10px; }

.bubble {
  max-width: 72%; padding: 10px 12px; border-radius: 8px;
  font-size: 15px; line-height: 1.55; position: relative;
  white-space: pre-wrap; word-break: break-all;
}
.msg-row.bot .bubble { background: #fff; }
.msg-row.me .bubble { background: var(--green); margin-right: 10px; }
.bubble a { color: #576b95; word-break: break-all; }

.bubble img.pic { max-width: 200px; max-height: 260px; border-radius: 6px; display: block; margin-top: 2px; }

.copy-btn {
  display: block; margin-top: 8px; padding: 3px 12px; font-size: 12px;
  border: 1px solid #d9d9d9; border-radius: 5px; background: #fafafa;
  color: #576b95; cursor: pointer;
}
.copy-btn:active { background: #eee; }

.typing .bubble { color: var(--sub); font-style: italic; }

/* ---------- 快捷栏 ---------- */
.quickbar {
  flex-shrink: 0; display: flex; border-top: 1px solid var(--line); background: #f7f7f7;
}
.quickbar button {
  flex: 1; padding: 11px 4px; font-size: 14px; color: #191919;
  background: none; border: none; cursor: pointer;
}
.quickbar button + button { border-left: 1px solid var(--line); }
.quickbar button:active { background: #ececec; }

/* ---------- 输入栏 ---------- */
.inputbar {
  flex-shrink: 0; display: flex; align-items: flex-end; gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: #f7f7f7; border-top: 1px solid var(--line);
}
/* 输入框外层：给「粘贴」按钮一个定位参照 */
.input-wrap { position: relative; flex: 1; min-width: 0; display: flex; }
.inputbar textarea {
  flex: 1; resize: none; border: none; outline: none; border-radius: 8px;
  /* 右侧留出「粘贴」按钮的位置，避免文字被盖住 */
  padding: 12px 64px 12px 12px;
  font-size: 15px; font-family: inherit; background: #fff; line-height: 1.5;
  min-height: 96px;          /* 常态约 3 行高，方便看链接全文、好点击 */
  max-height: 200px;
}
/* 输入框内部的「粘贴」按钮（右下角） */
.btn-paste {
  position: absolute; right: 8px; bottom: 9px; z-index: 2;
  padding: 5px 11px; font-size: 12.5px; line-height: 1.2; font-family: inherit;
  border: 1px solid #d9d9d9; border-radius: 13px;
  background: #fafafa; color: #576b95; cursor: pointer;
}
.btn-paste:active { background: #eef2f7; }
.btn-send {
  padding: 11px 20px; border: none; border-radius: 8px; background: #07c160;
  color: #fff; font-size: 15px; cursor: pointer; flex-shrink: 0;
}
.btn-send:disabled { opacity: .5; }

/* 通用确认框正文 */
.confirm-text {
  font-size: 13.5px; color: #4b5563; line-height: 1.8;
  margin: 4px 0 2px; white-space: pre-wrap; text-align: center;
}
.modal-card textarea {
  width: 100%; margin-top: 10px; padding: 10px 12px; font-size: 14px;
  font-family: inherit; line-height: 1.5; resize: none;
  border: 1px solid #ddd; border-radius: 8px; outline: none;
}
.modal-card textarea:focus { border-color: #07c160; }

/* ---------- 偏好设置弹层（固定一个转码路径，发链接直接出结果） ---------- */
.pref-tip {
  font-size: 12.5px; color: #6b7280; line-height: 1.7;
  margin: -6px 0 14px; text-align: center;
}
.pref-tip b { color: #07c160; }
.pref-sec { margin-bottom: 14px; text-align: left; }
.pref-h { font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 7px; }
.pref-opts { display: flex; flex-direction: column; gap: 7px; max-height: 40vh; overflow-y: auto; }
.pref-opt {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 10px 12px; font-family: inherit; font-size: 14px; text-align: left;
  border: 1px solid #e5e7eb; border-radius: 9px; background: #fff; color: #191919;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.pref-opt .po-dot {
  flex: 0 0 auto; width: 15px; height: 15px; border-radius: 50%;
  border: 1.5px solid #cbd5e1; background: #fff; box-sizing: border-box;
}
.pref-opt .po-t { flex: 1; min-width: 0; }
.pref-opt .po-s { flex: 0 0 auto; font-size: 12px; color: #98a2b3; white-space: nowrap; }
.pref-opt.on { border-color: #07c160; background: #f0fdf4; color: #067a3e; font-weight: 600; }
.pref-opt.on .po-dot { border-color: #07c160; background: #07c160; box-shadow: inset 0 0 0 2.5px #fff; }
.pref-opt.on .po-s { color: #3f9c6d; }
.pref-opt.off { opacity: .5; cursor: not-allowed; }
.pref-opt:not(.off):active { background: #f2f3f5; }
.pref-opt.on:active { background: #e8fbef; }
@media (hover: hover) {
  .pref-opt:not(.off):hover { border-color: #b9e6cb; }
}

/* 底部快捷栏里的「偏好设置」：与后台配置的快捷按钮同排，但用主色轻微区分 */
.quickbar button.quick-pref { color: #07c160; font-weight: 600; }
/* 已设置偏好：按钮上带一个小圆点，一眼看出「现在是直出模式」 */
.quickbar button.quick-pref.on::after {
  content: ''; display: inline-block; width: 6px; height: 6px; margin-left: 5px;
  border-radius: 50%; background: #07c160; vertical-align: 2px;
}

/* 轻提示 */
.toast {
  position: fixed; left: 50%; bottom: 14%; z-index: 300;
  transform: translateX(-50%) translateY(8px);
  max-width: 80vw; padding: 9px 16px; border-radius: 20px;
  background: rgba(0,0,0,.78); color: #fff; font-size: 13.5px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 登录 / 注册 ---------- */
.auth-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.auth-card {
  width: 340px; max-width: 100%; background: #fff; border-radius: 14px;
  padding: 28px 26px; box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
.auth-logo {
  width: 54px; height: 54px; margin: 0 auto 14px; border-radius: 12px;
  background: #1e6fff; color: #fff; font-size: 22px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.auth-tabs { display: flex; margin-bottom: 18px; border-bottom: 1px solid #eee; }
.auth-tabs .tab {
  flex: 1; padding: 10px; font-size: 15px; background: none; border: none;
  cursor: pointer; color: var(--sub); border-bottom: 2px solid transparent;
}
.auth-tabs .tab.active { color: #07c160; border-bottom-color: #07c160; font-weight: 600; }
.auth-card input {
  width: 100%; padding: 11px 12px; margin-bottom: 12px; font-size: 15px;
  border: 1px solid #ddd; border-radius: 8px; outline: none;
}
.auth-card input:focus { border-color: #07c160; }
.btn-primary {
  width: 100%; padding: 12px; border: none; border-radius: 8px;
  background: #07c160; color: #fff; font-size: 16px; cursor: pointer;
}
.btn-primary:active { opacity: .85; }
.auth-err { margin-top: 10px; font-size: 13px; color: #fa5151; text-align: center; min-height: 18px; }
/* 注册验证码行：输入框 + 可点击刷新的验证码图 */
.cap-row { display: flex; gap: 10px; align-items: stretch; margin-bottom: 12px; }
.cap-row input {
  flex: 1; min-width: 0; width: auto; padding: 8px 12px; font-size: 15px; letter-spacing: 4px;
  border: 1px solid #ddd; border-radius: 8px; outline: none; margin-bottom: 0;
  text-transform: uppercase;
}
.cap-row input:focus { border-color: #07c160; }
.cap-row img {
  height: 42px; width: 118px; flex: 0 0 118px; border-radius: 8px; cursor: pointer;
  border: 1px solid #e5e7eb; background: #f7f9fc; object-fit: cover;
}
.cap-err-tip { font-size: 12px; color: var(--sub); text-align: center; margin: -6px 0 10px; }

/* ---------- 充值弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 120;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  width: 360px; max-width: 100%; background: #fff; border-radius: 14px;
  padding: 24px 22px; box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
.modal-title { font-size: 17px; font-weight: 600; text-align: center; margin-bottom: 16px; }
.amounts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.amounts button {
  flex: 1; min-width: 60px; padding: 9px 0; font-size: 14px; cursor: pointer;
  border: 1px solid #ddd; border-radius: 8px; background: #fff; color: #191919;
}
.amounts button.on { border-color: #07c160; color: #07c160; background: #f0fdf4; font-weight: 600; }
.modal-card input[type=number] {
  width: 100%; padding: 11px 12px; font-size: 15px; border: 1px solid #ddd;
  border-radius: 8px; outline: none; margin-bottom: 14px;
}
.modal-card input[type=number]:focus { border-color: #07c160; }
.chan-label { font-size: 13px; color: var(--sub); margin-bottom: 8px; }
.channels { display: flex; gap: 8px; margin-bottom: 18px; }
.channels button {
  flex: 1; padding: 10px 0; font-size: 14px; cursor: pointer; border-radius: 8px;
  border: 1px solid #ddd; background: #fff; color: #191919;
}
.channels button.on { border-color: #07c160; color: #07c160; background: #f0fdf4; font-weight: 600; }
.channels button .ico { margin-right: 4px; }
.modal-btns { display: flex; gap: 10px; }
.modal-btns .btn-cancel {
  flex: 1; padding: 12px; border: 1px solid #ddd; border-radius: 8px;
  background: #fff; color: #555; font-size: 15px; cursor: pointer;
}
.modal-btns .btn-primary { flex: 1.6; }
.modal-tip { margin-top: 10px; font-size: 12px; color: var(--sub); line-height: 1.6; text-align: center; }

/* ---------- 自动回复菜单（转码类型做成可点击超链） ---------- */
.msg-row.bot .bubble.bubble-menu { padding: 10px 10px 9px; max-width: min(88vw, 470px); }
.menu { display: flex; flex-direction: column; gap: 6px; }
.menu-title { font-weight: 600; font-size: 14px; }
.menu-sub { font-size: 13px; color: var(--sub); }
.menu-line { font-size: 13px; color: var(--sub); line-height: 1.6; }
.menu-foot { margin-top: 5px; font-size: 12px; color: var(--sub); line-height: 1.6; }

.menu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: 8px; text-decoration: none;
  background: #f2f3f5; border: 1px solid #e6e8eb;
  color: #576b95; font-size: 14px; line-height: 1.4;
  word-break: normal;
  transition: background .15s, border-color .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.menu-item:active { background: #e6efff; border-color: #c4d7f7; transform: scale(.995); }
@media (hover: hover) {
  .menu-item:hover { background: #e6efff; border-color: #c4d7f7; }
}
.mi-idx { flex: 0 0 auto; font-size: 15px; color: #576b95; }
.mi-name { flex: 1; min-width: 0; word-break: break-all; }
.mi-price { flex: 0 0 auto; font-size: 12px; color: #07c160; white-space: nowrap; font-weight: 600; }
.mi-free { flex: 0 0 auto; font-size: 12px; color: #fff; background: #07c160; border-radius: 4px;
  padding: 1px 6px; white-space: nowrap; font-weight: 600; }

/* 二维码（本地生成，长按/右键可保存） */
.bubble-qr { background: #fff; padding: 8px; }
.qr-box { display: inline-flex; background: #fff; border-radius: 8px; }
.qr-box img, .qr-img { display: block; width: 230px; height: 230px; }
@media (max-width: 420px) { .qr-box img, .qr-img { width: 200px; height: 200px; } }

/* 菜单超过有效期：整体置灰 + 不可点 */
.menu.expired .menu-item {
  background: #f5f5f5; border-color: #e8e8e8; color: #b3b3b3;
  cursor: not-allowed;
}
.menu.expired .mi-idx, .menu.expired .mi-price { color: #bfbfbf; }
.menu.expired .menu-item:active { background: #f5f5f5; border-color: #e8e8e8; transform: none; }
.menu-expired-tip { font-size: 12px; color: #fa5151; line-height: 1.6; }

/* 狂点「菜单」时：定位高亮已有的菜单，提示它就在上面 */
.menu-flash { animation: menuFlash 1.2s ease; }
@keyframes menuFlash {
  0%   { box-shadow: 0 0 0 0 rgba(7, 193, 96, .55); }
  35%  { box-shadow: 0 0 0 6px rgba(7, 193, 96, .35); }
  100% { box-shadow: 0 0 0 0 rgba(7, 193, 96, 0); }
}

/* ---------- 全局弹窗 ---------- */
.popup-mask {
  position: fixed; inset: 0; z-index: 999; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.popup-card {
  width: 400px; max-width: 100%; background: #fff; border-radius: 16px;
  padding: 26px 22px 20px; box-shadow: 0 14px 48px rgba(0,0,0,.3);
  animation: popupIn .22s ease-out;
}
@keyframes popupIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.popup-title { font-size: 18px; font-weight: 700; text-align: center; margin-bottom: 14px; }
.popup-body {
  font-size: 14.5px; line-height: 1.8; color: #333; max-height: 56vh; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word; margin-bottom: 20px;
}
.popup-card .btn-primary { width: 100%; }
