/* ============================================================================
   我的硅基人 · Web（PWA）样式
   对齐 Android 端：主色 #2196F3、AI 气泡 #E8E8E8、自己气泡 #2196F3、
   发送键 #07C160、技能条 #EAF2FB。
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: #fff; color: #333;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
body { overflow: hidden; }
button, input, textarea { font-family: inherit; }
button { cursor: pointer; }

/* ── 登录 ───────────────────────────────────────────────────────────── */
.login-screen {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  background: linear-gradient(160deg, #1976D2 0%, #2196F3 42%, #EAF2FB 42%, #F7FAFF 100%);
  padding: calc(env(safe-area-inset-top) + 34px) 22px calc(env(safe-area-inset-bottom) + 20px);
  overflow-y: auto;
}
.login-hero { text-align: center; color: #fff; padding: 6px 0 26px; }
.login-logo {
  width: 76px; height: 76px; border-radius: 19px;
  box-shadow: 0 10px 26px rgba(0,0,0,.22);
}
.login-app-name { font-size: 22px; font-weight: 700; margin-top: 12px; letter-spacing: .5px; }
.login-app-sub { font-size: 12px; opacity: .82; margin-top: 5px; letter-spacing: .4px; }
.login-card {
  background: #fff; border-radius: 18px; padding: 18px 18px 16px;
  box-shadow: 0 8px 30px rgba(16, 62, 110, .12);
}
.login-tabs { display: flex; gap: 18px; margin-bottom: 14px; }
.login-tab {
  border: 0; background: none; padding: 4px 2px; font-size: 16px; color: #8a8f99;
  border-bottom: 2px solid transparent;
}
.login-tab.active { color: #2196F3; font-weight: 600; border-bottom-color: #2196F3; }
.field { display: block; margin-bottom: 13px; }
.field span { display: block; font-size: 12px; color: #8a8f99; margin-bottom: 6px; }
.field input {
  width: 100%; height: 44px; border: 1px solid #e2e6ec; border-radius: 10px;
  padding: 0 12px; font-size: 15px; color: #222; background: #fafbfd; outline: none;
}
.field input:focus { border-color: #2196F3; background: #fff; }
.btn-primary {
  width: 100%; height: 46px; border: 0; border-radius: 10px; margin-top: 4px;
  background: #2196F3; color: #fff; font-size: 16px; font-weight: 600;
  box-shadow: 0 6px 16px rgba(33,150,243,.28);
}
.btn-primary:disabled { opacity: .6; box-shadow: none; }
.login-error { color: #E53935; font-size: 13px; min-height: 18px; margin-top: 8px; text-align: center; }
.login-help { text-align: center; font-size: 11px; color: #a0a6b0; margin-top: 4px; }

/* ── 主框架 ─────────────────────────────────────────────────────────── */
.app-screen { position: fixed; inset: 0; display: flex; flex-direction: column; background: #fff; }
.tab-page {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  padding-bottom: calc(58px + env(safe-area-inset-bottom));
}
.topbar {
  flex: 0 0 auto; height: 50px; background: #2196F3; color: #fff;
  display: flex; align-items: center; padding: 0 12px 0 16px;
  padding-top: env(safe-area-inset-top);
  height: calc(50px + env(safe-area-inset-top));
  box-shadow: 0 1px 4px rgba(0,0,0,.10);
}
.topbar-title { flex: 1; font-size: 18px; font-weight: 600; letter-spacing: .3px; }
.topbar-actions { display: flex; align-items: center; gap: 2px; }
.icon-btn {
  width: 38px; height: 38px; border: 0; background: transparent; color: #fff;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
}
.icon-btn:active { background: rgba(255,255,255,.18); }
.icon-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ws-dot { width: 8px; height: 8px; border-radius: 50%; background: #86efac; margin-right: 4px; box-shadow: 0 0 0 3px rgba(134,239,172,.25); }
.ws-dot.off { background: #cbd5e1; box-shadow: none; }

/* ── 技能条 ─────────────────────────────────────────────────────────── */
.skill-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; background: #EAF2FB; border-bottom: 1px solid #dbe8f7;
}
.chip {
  border: 1px solid #4A90D9; background: #F0F7FF; color: #1b6fbf;
  border-radius: 15px; padding: 5px 13px; font-size: 13px; line-height: 1;
}
.chip:active { background: #dcecfd; }
.skill-hint { font-size: 12px; color: #8A8A8E; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── 对话 ───────────────────────────────────────────────────────────── */
.chat-scroll { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; background: #fff; }
.chat-list { padding: 10px 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; flex-direction: column; max-width: 82%; }
.msg.ai { align-self: flex-start; align-items: flex-start; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.bubble {
  padding: 9px 12px; border-radius: 16px; font-size: 15px; line-height: 1.55;
  word-break: break-word; white-space: pre-wrap; position: relative;
}
.msg.ai .bubble { background: #E8E8E8; color: #333; border-top-left-radius: 4px; }
.msg.me .bubble { background: #2196F3; color: #fff; border-top-right-radius: 4px; }
.bubble .time { display: block; font-size: 10px; color: rgba(0,0,0,.35); margin-top: 4px; text-align: right; }
.msg.me .bubble .time { color: rgba(255,255,255,.7); }
.bubble img { max-width: 100%; border-radius: 10px; display: block; margin: 4px 0; }
.bubble code { background: rgba(0,0,0,.06); padding: 1px 4px; border-radius: 4px; font-size: 13px; }
.msg.me .bubble code { background: rgba(255,255,255,.18); }
.bubble pre {
  background: #0f172a; color: #e8eef7; padding: 10px; border-radius: 8px;
  overflow-x: auto; font-size: 12.5px; margin: 6px 0; white-space: pre;
}
.bubble a { color: #007AFF; }
.msg.me .bubble a { color: #e3f2ff; text-decoration: underline; }
.msg .meta { font-size: 10px; color: #b0b6bf; margin-top: 3px; padding: 0 4px; }
.typing { display: inline-flex; gap: 3px; align-items: center; height: 18px; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: #9aa3ad; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,60%,100% { opacity: .25; } 30% { opacity: 1; } }
.day-sep { align-self: center; font-size: 11px; color: #a5abb4; background: #f2f4f7; padding: 2px 10px; border-radius: 10px; }

/* 搜索栏 */
.search-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; background: #F5F5F5; border-bottom: 1px solid #e6e6e6;
}
.search-bar input {
  flex: 1; height: 34px; border: 1px solid #d6dae0; border-radius: 8px;
  padding: 0 10px; font-size: 14px; background: #fff; outline: none;
}
.search-hits { font-size: 12px; color: #FF9800; min-width: 28px; }
.search-bar .icon-btn { color: #666; width: 32px; height: 32px; }

/* 暂存附件 */
.staged-bar { flex: 0 0 auto; background: #EEF4FB; border-top: 1px solid #dde8f4; padding: 6px 10px; }
.staged-head { display: flex; justify-content: space-between; font-size: 12px; color: #4A4A4A; }
.staged-head button { border: 0; background: none; color: #E53935; font-size: 12px; }
.staged-list { display: flex; gap: 8px; overflow-x: auto; padding-top: 6px; }
.staged-item {
  position: relative; flex: 0 0 auto; width: 62px; height: 62px; border-radius: 8px;
  background: #fff; border: 1px solid #dbe4ef; display: flex; align-items: center;
  justify-content: center; font-size: 10px; color: #5a6472; text-align: center; overflow: hidden;
}
.staged-item img { width: 100%; height: 100%; object-fit: cover; }
.staged-item .x {
  position: absolute; top: 1px; right: 1px; width: 16px; height: 16px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; font-size: 11px; line-height: 16px; border: 0;
}

/* 输入栏 */
.input-bar {
  flex: 0 0 auto; display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: #F7F7F7; border-top: 1px solid #e8e8e8;
}
.attach-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid #d6dae0;
  background: #fff; color: #4a5460; display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.attach-btn svg, .send-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#chatInput {
  flex: 1; min-height: 36px; max-height: 120px; resize: none;
  border: 1px solid #dfe3e8; border-radius: 18px; padding: 8px 13px;
  font-size: 15px; line-height: 20px; background: #fff; outline: none; color: #222;
}
#chatInput:focus { border-color: #a9d2f7; }
.send-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: #07C160; color: #fff;
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.send-btn:disabled { background: #b9c2cb; }
.send-btn svg { stroke-width: 2.2; }

/* ── 列表页 ─────────────────────────────────────────────────────────── */
.scroll-page { flex: 1 1 auto; overflow-y: auto; background: #F5F7FA; padding: 10px 12px 20px; }
.zhigu-search { padding: 8px 12px; background: #fff; border-bottom: 1px solid #eef1f5; }
.zhigu-search input {
  width: 100%; height: 38px; border-radius: 19px; border: 1px solid #e2e6ec;
  background: #f7f9fc; padding: 0 14px; font-size: 14px; outline: none;
}
.k-card {
  background: #fff; border-radius: 12px; padding: 12px 13px; margin-bottom: 9px;
  box-shadow: 0 1px 3px rgba(16,42,74,.06);
}
.k-title { font-size: 15px; font-weight: 600; color: #1f2a37; margin-bottom: 5px; }
.k-body { font-size: 13px; color: #5a6472; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.k-meta { display: flex; justify-content: space-between; font-size: 11px; color: #9aa3ad; margin-top: 8px; }
.k-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 7px; }
.k-tag { font-size: 10px; color: #2c7be5; background: #eaf2fb; border-radius: 8px; padding: 2px 7px; }
.friend-row {
  display: flex; align-items: center; gap: 11px; background: #fff; border-radius: 12px;
  padding: 12px 13px; margin-bottom: 8px; box-shadow: 0 1px 3px rgba(16,42,74,.06);
}
.friend-avatar {
  width: 42px; height: 42px; border-radius: 12px; background: #2196F3; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 600;
}
.friend-main { flex: 1; min-width: 0; }
.friend-name { font-size: 15px; color: #1f2a37; }
.friend-sub { font-size: 12px; color: #9aa3ad; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; }
.online-dot.off { background: #cbd5e1; }
.empty-mini { text-align: center; color: #9aa3ad; font-size: 13px; padding: 18px 0; }

/* ── 个人中心 ───────────────────────────────────────────────────────── */
.profile-card {
  display: flex; align-items: center; gap: 13px; background: linear-gradient(135deg,#2196F3,#1976D2);
  border-radius: 14px; padding: 16px; color: #fff; margin-bottom: 10px;
  box-shadow: 0 6px 18px rgba(33,150,243,.25);
}
.avatar {
  width: 54px; height: 54px; border-radius: 16px; background: rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700;
}
.profile-name { font-size: 18px; font-weight: 600; }
.profile-sub { font-size: 12px; opacity: .85; margin-top: 4px; }
.stat-row { display: flex; background: #fff; border-radius: 12px; padding: 13px 0; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(16,42,74,.06); }
.stat-item { flex: 1; text-align: center; position: relative; }
.stat-item + .stat-item::before { content: ''; position: absolute; left: 0; top: 4px; bottom: 4px; width: 1px; background: #eef1f5; }
.stat-num { font-size: 17px; font-weight: 700; color: #1f2a37; }
.stat-label { font-size: 11px; color: #9aa3ad; margin-top: 3px; }
.card { background: #fff; border-radius: 12px; margin-bottom: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(16,42,74,.06); }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; font-size: 14px; color: #1f2a37; font-weight: 600; border-bottom: 1px solid #f0f3f7; }
.mini-btn { border: 1px solid #d8e2ee; background: #f7fafd; color: #2c7be5; border-radius: 8px; padding: 4px 10px; font-size: 12px; font-weight: 500; }
.device-list { padding: 4px 14px 10px; }
.device-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f3f5f8; }
.device-row:last-child { border-bottom: 0; }
.device-icon { width: 34px; height: 34px; border-radius: 10px; background: #eef4fc; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.device-main { flex: 1; min-width: 0; }
.device-name { font-size: 14px; color: #1f2a37; }
.device-sub { font-size: 11px; color: #9aa3ad; margin-top: 2px; }
.device-state { font-size: 11px; padding: 3px 8px; border-radius: 9px; background: #e9f8ef; color: #128a4b; }
.device-state.off { background: #f1f3f6; color: #8b95a1; }
.list-row {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 13px 14px;
  border: 0; border-bottom: 1px solid #f3f5f8; background: #fff; font-size: 14px; color: #1f2a37;
  text-align: left; text-decoration: none;
}
.list-row:last-child { border-bottom: 0; }
.list-row:active { background: #f7f9fc; }
.row-icon { width: 22px; text-align: center; }
.row-text { flex: 1; }
.row-text.danger { color: #E53935; }
.row-arrow { color: #c2c9d2; font-size: 18px; }
.version { text-align: center; font-size: 11px; color: #aab1ba; padding: 14px 0 4px; }

/* ── 底部导航 ───────────────────────────────────────────────────────── */
.bottom-nav {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: #fff; border-top: 1px solid #e8ebef;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1; height: 57px; border: 0; background: none; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: #9aa3ad; font-size: 10.5px;
}
.nav-item svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-item.active { color: #2196F3; }
.nav-badge { position: absolute; top: 7px; right: 28%; width: 7px; height: 7px; background: #E53935; border-radius: 50%; }

/* ── 弹层 ───────────────────────────────────────────────────────────── */
.sheet-mask { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.42); display: flex; align-items: flex-end; }
.sheet {
  width: 100%; background: #fff; border-radius: 16px 16px 0 0; max-height: 72vh;
  display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom);
  animation: slideUp .18s ease-out;
}
@keyframes slideUp { from { transform: translateY(24px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid #f0f3f7; font-size: 15px; font-weight: 600; }
.sheet-head button { border: 0; background: none; font-size: 20px; color: #9aa3ad; line-height: 1; }
.sheet-body { overflow-y: auto; padding: 8px 10px 14px; }
.sheet-item { display: flex; align-items: center; gap: 11px; padding: 12px; border-radius: 10px; }
.sheet-item:active { background: #f5f8fc; }
.sheet-item .ico { width: 34px; height: 34px; border-radius: 10px; background: #eef4fc; display: flex; align-items: center; justify-content: center; font-size: 17px; }
.sheet-item .t { font-size: 14px; color: #1f2a37; }
.sheet-item .d { font-size: 11px; color: #9aa3ad; margin-top: 2px; }

/* ── 安装/更新提示 ──────────────────────────────────────────────────── */
.install-chip {
  position: fixed; right: 14px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 40;
  display: flex; align-items: center; gap: 8px; padding: 8px 9px 8px 14px;
  background: linear-gradient(135deg,#1e3a8a,#0f3460); color: #e8eef7;
  border-radius: 999px; font-size: 13px; border: 1px solid rgba(255,255,255,.16);
  box-shadow: 0 8px 26px rgba(0,0,0,.35);
}
.install-chip button { border: 0; border-radius: 999px; font-size: 13px; }
#installChipBtn { background: #2196F3; color: #fff; padding: 6px 13px; font-weight: 600; }
.chip-close { width: 22px; height: 22px; background: rgba(255,255,255,.14); color: #cbd5e1; }
.update-bar {
  position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%);
  z-index: 50; display: flex; align-items: center; gap: 12px; padding: 9px 12px 9px 16px;
  background: #0b3b2e; color: #d1fae5; border-radius: 12px; font-size: 13px;
  border: 1px solid rgba(16,185,129,.35); box-shadow: 0 8px 26px rgba(0,0,0,.3);
}
.update-bar button { border: 0; border-radius: 8px; background: #10b981; color: #062b20; font-weight: 600; padding: 6px 12px; font-size: 13px; }
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 8px); z-index: 80;
  background: rgba(17,24,39,.9); color: #fff; font-size: 13px; padding: 9px 16px;
  border-radius: 10px; opacity: 0; pointer-events: none; transition: all .22s; max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 独立窗口模式：去掉多余留白 */
@media (display-mode: standalone) {
  .install-chip { display: none !important; }
}

/* 私密通信 · 信令状态条 */
.signal-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; background: #f2f7fd; border-bottom: 1px solid #e2ecf7;
  font-size: 12.5px; color: #3b4a5a;
}
.sig-dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; flex: 0 0 auto; }
.sig-dot.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
.sig-dot.wait { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.16); }
.sig-dot.off { background: #cbd5e1; }
.sig-right { margin-left: auto; color: #7a8592; font-size: 11.5px; }
