/* 桌宠手机聊天页 —— 与桌面端一致的“深色圆角浮层 + 可爱系” */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #141418;
  --panel: rgba(28, 28, 32, 0.94);
  --panel-line: rgba(255, 255, 255, 0.10);
  --text: #f0f0f4;
  --text-dim: #9a9aa4;
  --accent: #4d7cff;
  --accent-soft: rgba(120, 160, 255, 0.34);
  --green: #54d17a;
  --red: #ff5f57;
  --amber: #ffb02e;
  --radius: 16px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}
.hidden { display: none !important; }

/* ===== 顶部状态条 ===== */
#topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + var(--sat)) 14px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--panel-line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.top-mid { flex: 1; min-width: 0; }
#top-title {
  font-size: 16px;
  font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#top-status {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-dim); margin-top: 2px;
}
#top-status .dot {
  width: 7px; height: 7px; border-radius: 999px; flex: 0 0 7px;
  background: #666;
}
#top-status.st-on .dot { background: var(--green); box-shadow: 0 0 0 3px rgba(84, 209, 122, 0.16); }
#top-status.st-mid .dot { background: var(--amber); box-shadow: 0 0 0 3px rgba(255, 176, 46, 0.16); }
#top-status.st-off .dot { background: var(--red); box-shadow: 0 0 0 3px rgba(255, 95, 87, 0.14); }
.top-ava {
  width: 34px; height: 34px; border-radius: 11px; flex: 0 0 34px;
  background: radial-gradient(circle at 50% 40%, #2a2a34, #1c1c22);
  border: 1px solid var(--panel-line);
  object-fit: contain;
}
.icon-btn {
  appearance: none; border: none; cursor: pointer;
  width: 34px; height: 34px; border-radius: 11px;
  font-size: 17px; line-height: 1;
  color: var(--text); background: rgba(255, 255, 255, 0.08);
  flex: 0 0 34px;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s;
}
#btn-back { font-size: 24px; padding-bottom: 3px; }
.icon-btn:active { background: var(--accent-soft); }

/* ===== 断线提示条 ===== */
#net-banner {
  flex: 0 0 auto;
  padding: 7px 14px;
  font-size: 12px;
  text-align: center;
  color: #3a2a00;
  background: var(--amber);
}
#net-banner.err { background: var(--red); color: #fff; }

/* ===== 视图通用 ===== */
.view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 16px calc(18px + var(--sab));
}
.card {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.42);
  padding: 16px;
}

/* ===== 连接页 ===== */
.hero { text-align: center; padding: 12px 0 22px; }
.hero-pet {
  width: 132px; height: 132px; object-fit: contain;
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.5));
  animation: bob 2.6s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-6px) scale(1.02); }
}
.hero h1 { font-size: 21px; margin-top: 6px; }
.hero-sub { font-size: 13px; color: var(--text-dim); margin-top: 7px; line-height: 1.55; }
.field { display: block; margin-bottom: 13px; }
.flabel {
  display: block;
  font-size: 11px; font-weight: 600; letter-spacing: .3px;
  color: var(--text-dim); margin-bottom: 6px;
}
.field input {
  appearance: none;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 11px;
  padding: 11px 12px;
  font-size: 15px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  outline: none;
  transition: border-color .12s;
}
.field input:focus { border-color: rgba(120, 160, 255, 0.6); }
.field input::placeholder { color: #6c6c76; }
button.primary {
  appearance: none; border: none; cursor: pointer;
  width: 100%;
  border-radius: 12px;
  font-size: 15px; font-weight: 650;
  color: #fff; background: var(--accent);
  transition: background .12s, transform .08s;
}
button.primary.big { padding: 13px 0; margin-top: 4px; }
button.primary:active { background: #3a68e6; transform: scale(.98); }
button.primary[disabled] { opacity: .55; }
.err {
  margin-top: 11px;
  padding: 9px 11px;
  border-radius: 10px;
  font-size: 12px;
  color: #ffb3af;
  background: rgba(255, 95, 87, 0.14);
  border: 1px solid rgba(255, 95, 87, 0.3);
}

/* ===== 设备页 ===== */
.sec-title {
  font-size: 12px; font-weight: 600; letter-spacing: .3px;
  color: var(--text-dim); margin: 2px 2px 10px;
}
.card.list { padding: 8px; }
.dev-item {
  appearance: none; border: none; cursor: pointer;
  display: flex; align-items: center; gap: 11px;
  width: 100%;
  padding: 12px 11px;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 15px;
  transition: background .12s;
}
.dev-item:active { background: var(--accent-soft); }
.dev-item + .dev-item { margin-top: 2px; }
.dev-ico {
  width: 40px; height: 40px; border-radius: 12px; flex: 0 0 40px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  background: linear-gradient(135deg, rgba(120, 160, 255, 0.28), rgba(77, 124, 255, 0.14));
  border: 1px solid var(--panel-line);
}
.dev-main { flex: 1; min-width: 0; }
.dev-name {
  font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dev-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.dev-dot {
  width: 8px; height: 8px; border-radius: 999px; flex: 0 0 8px;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(84, 209, 122, 0.16);
}
.empty { text-align: center; padding: 44px 0; color: var(--text-dim); font-size: 14px; }
.empty-pet {
  width: 108px; height: 108px; object-fit: contain;
  opacity: .8;
  filter: grayscale(.25) drop-shadow(0 8px 18px rgba(0, 0, 0, 0.45));
  margin-bottom: 10px;
}
.empty-sub { font-size: 12px; margin-top: 5px; opacity: .75; }

/* ===== 聊天窗 ===== */
#view-chat {
  display: flex;
  flex-direction: column;
  padding: 0;
}
#msgs {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-empty { text-align: center; color: var(--text-dim); font-size: 13px; padding: 40px 0 10px; }
.row { display: flex; align-items: flex-end; gap: 8px; }
.row.me { flex-direction: row-reverse; }
.bub-ava {
  width: 32px; height: 32px; border-radius: 10px; flex: 0 0 32px;
  object-fit: contain;
  background: radial-gradient(circle at 50% 40%, #2a2a34, #1c1c22);
  border: 1px solid var(--panel-line);
}
.bub {
  max-width: 76%;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  animation: popin .16s ease both;
}
@keyframes popin { from { opacity: 0; transform: scale(.94) translateY(4px); } to { opacity: 1; transform: none; } }
.row.pet .bub {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-bottom-left-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.32);
}
.row.me .bub {
  background: linear-gradient(135deg, #5d88ff, #3f6cf0);
  border-bottom-right-radius: 6px;
  box-shadow: 0 6px 20px rgba(63, 108, 240, 0.32);
}
.row.sys { justify-content: center; }
.row.sys .bub {
  max-width: 88%;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.06);
}
.bub.pending { opacity: .6; }

/* 输入区 */
#composer {
  flex: 0 0 auto;
  padding: 8px 12px calc(10px + var(--sab));
  background: var(--panel);
  border-top: 1px solid var(--panel-line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
#cmd-bar {
  display: flex; gap: 7px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}
#cmd-bar::-webkit-scrollbar { display: none; }
.chip {
  appearance: none; border: none; cursor: pointer;
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.10);
  transition: background .12s, transform .08s;
}
.chip:active { background: var(--accent-soft); transform: scale(.96); }
#input-row { display: flex; gap: 8px; align-items: center; }
#in-msg {
  appearance: none;
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 10px 15px;
  font-size: 16px;               /* ≥16px：避免 iOS 聚焦自动放大 */
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}
#in-msg:focus { border-color: rgba(120, 160, 255, 0.6); }
.round-btn {
  appearance: none; border: none; cursor: pointer;
  width: 42px; height: 42px; border-radius: 999px; flex: 0 0 42px;
  font-size: 17px; line-height: 1;
  color: var(--text); background: rgba(255, 255, 255, 0.10);
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, box-shadow .1s;
  touch-action: none;            /* 按住说话时禁止页面滚动 */
  -webkit-user-select: none; user-select: none;
}
.round-btn.send { background: var(--accent); color: #fff; }
.round-btn.send:active { background: #3a68e6; }
.round-btn:active { background: var(--accent-soft); }
#btn-mic.listening {
  --vol: 0;
  background: var(--red); color: #fff;
  box-shadow: 0 0 0 calc(3px + var(--vol) * 9px) rgba(255, 95, 87, 0.28);
  animation: micpulse 1.1s infinite;
}
@keyframes micpulse { 0%, 100% { box-shadow: 0 0 0 3px rgba(255,95,87,.28); } 50% { box-shadow: 0 0 0 10px rgba(255,95,87,.12); } }
#mic-hint {
  margin-top: 7px;
  font-size: 11px;
  text-align: center;
  color: var(--red);
}

/* ---------- 配对流程遮罩（等待电脑同意 / SAS 校验码核对） ---------- */
/* 配对确认：聊天区内居中的实心卡片（不再是铺满的遮罩） */
.pair-overlay {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 30; width: calc(100% - 40px); max-width: 320px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 26px 22px;
  background: var(--card, #1c1c20);
  border: 1px solid rgba(255,255,255,.10); border-radius: 20px;
  box-shadow: 0 18px 50px rgba(0,0,0,.55);
  text-align: center;
}
.pair-overlay .empty-pet { width: 64px; height: 64px; }
.pair-overlay p { font-size: 14px; color: var(--text-dim, #9aa); line-height: 1.6; margin: 0; }
.pair-sas {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 34px; font-weight: 800; letter-spacing: 4px;
  color: var(--accent, #4d7cff);
  padding: 10px 22px; border: 1px dashed var(--accent, #4d7cff); border-radius: 14px;
}
.pair-btns { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 280px; margin-top: 6px; }
.pair-btns .primary { padding: 12px 0; border-radius: 12px; }
.pair-cancel {
  padding: 11px 0; border-radius: 12px; font-size: 14px;
  background: transparent; color: var(--text-dim, #9aa);
  border: 1px solid rgba(255,255,255,.16);
}
#view-chat { position: relative; }   /* 配对遮罩的定位基准 */

/* ===== 好友页 ===== */
#view-friends .sec-title { margin-top: 18px; }
#view-friends .sec-title:first-child { margin-top: 2px; }
#view-friends .card + .card { margin-top: 0; }

/* 电脑名片 */
.mecard { padding: 14px 16px; }
.mecard-row { display: flex; align-items: center; gap: 10px; }
.mecard-main { flex: 1; min-width: 0; }
.mecard-nick { font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mecard-pid {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px; color: var(--accent); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  user-select: all; -webkit-user-select: all;
}
.mecard-hint { font-size: 11px; color: var(--text-dim); margin-top: 10px; line-height: 1.5; }

/* 小按钮（复制 / 同意 / 拒绝 / 删除） */
.mini-btn {
  appearance: none; border: none; cursor: pointer;
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px; font-weight: 600;
  color: var(--text); background: rgba(255, 255, 255, 0.12);
  transition: background .12s, transform .08s;
}
.mini-btn:active { transform: scale(.95); }
.mini-btn.ok { color: #fff; background: var(--accent); }
.mini-btn.del, .mini-btn.err { color: #ffb3af; background: rgba(255, 95, 87, 0.16); }

/* 添加好友输入行 */
.add-row { display: flex; gap: 8px; align-items: center; }
.add-row input {
  appearance: none;
  flex: 1; min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 11px;
  padding: 10px 12px;
  font-size: 16px;               /* ≥16px 防 iOS 聚焦放大 */
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}
.add-row input:focus { border-color: rgba(120, 160, 255, 0.6); }
.add-row input::placeholder { color: #6c6c76; font-size: 13px; }
button.primary.add-btn { width: auto; flex: 0 0 auto; padding: 10px 16px; }
.add-hint {
  margin-top: 10px; padding: 8px 11px;
  border-radius: 10px; font-size: 12px;
  color: var(--text-dim); background: rgba(255, 255, 255, 0.06);
}
.add-hint.err { color: #ffb3af; background: rgba(255, 95, 87, 0.14); }

/* 好友 / 待处理条目 */
.fr-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 11px;
  border-radius: 12px;
}
.fr-item + .fr-item { margin-top: 2px; border-top: 1px solid var(--panel-line); border-radius: 0; padding-top: 13px; }
.fr-main { flex: 1; min-width: 0; }
.fr-name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fr-pid {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px; color: var(--text-dim); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fr-acts { display: flex; gap: 6px; flex: 0 0 auto; }
