/* ============================================================
   LDchat Mobile — Glassmorphism 2.0 Design System
   Brand: Emerald → Teal gradient (#06D6A0 → #1B9AAA)
   ============================================================ */

/* ==================== Design Tokens ==================== */
:root {
  /* Brand Gradient */
  --brand: #0FA878;
  --brand-2: #0C9468;
  --brand-3: #06D6A0;
  --brand-deep: #074B3A;
  --brand-light: #E6FAF2;
  --brand-glow: rgba(6, 214, 160, 0.25);

  /* Surfaces */
  --bg: #F2F4F7;
  --bg-warm: #F8F9FB;
  --card: #FFFFFF;
  --card-hover: #FAFBFC;
  --card-glass: rgba(255, 255, 255, 0.72);
  --card-glass-border: rgba(255, 255, 255, 0.45);

  /* Text */
  --text: #1A1D23;
  --text-2: #5F6672;
  --text-3: #9CA3B0;
  --text-inverse: #FFFFFF;

  /* Semantic */
  --danger: #EF4444;
  --danger-soft: #FEF2F2;
  --warn: #F59E0B;
  --ok: #22C55E;
  --ok-soft: #F0FDF4;
  --info: #3B82F6;

  /* Elevation */
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --radius-full: 999px;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.16);
  --shadow-brand: 0 4px 20px rgba(15, 168, 120, 0.3);
  --shadow-brand-lg: 0 8px 32px rgba(15, 168, 120, 0.35);

  /* Glass */
  --glass-bg: rgba(255, 255, 255, 0.68);
  --glass-border: 1px solid rgba(255, 255, 255, 0.4);
  --glass-blur: blur(20px);

  /* Spacing (4px grid) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 28px; --sp-8: 32px;

  /* Safe areas */
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);

  /* Animation */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;
}

/* ==================== Reset & Base ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app { position: fixed; top: 0; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; overflow: hidden; }
.page { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; overflow: hidden; }

/* ==================== Animations ==================== */
@keyframes pageIn { from { transform: translateX(100%); opacity: 0.5; } to { transform: none; opacity: 1; } }
@keyframes pageBack { from { transform: translateX(-20%); opacity: 0.6; } to { transform: none; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { transform: scale(0.92) translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes scaleIn { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes ripple { to { transform: scale(4); opacity: 0; } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

.page.anim-in { animation: pageIn 0.3s var(--ease-out); will-change: transform, opacity; }
.page.anim-back { animation: pageBack 0.3s var(--ease-out); will-change: transform, opacity; }

/* ==================== Bind Page ==================== */
.bind-page {
  align-items: center;
  justify-content: center;
  padding: 32px 24px calc(32px + var(--safe-bottom));
  background: linear-gradient(160deg, #043D2E 0%, #074B3A 30%, #0A6B50 60%, #0FA878 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.bind-page::before {
  content: "";
  position: absolute;
  top: -30%;
  right: -20%;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(6, 214, 160, 0.2) 0%, transparent 70%);
  pointer-events: none;
}
.bind-page::after {
  content: "";
  position: absolute;
  bottom: -20%;
  left: -15%;
  width: 250px;
  height: 250px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(27, 154, 170, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

.bind-card {
  width: 100%;
  max-width: 370px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-xl);
  padding: 32px 24px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  animation: scaleIn 0.4s var(--ease-spring);
  position: relative;
  z-index: 1;
  will-change: transform, opacity;
}

.bind-logo { text-align: center; margin-bottom: 24px; }
.bind-logo img {
  width: 80px; height: 80px;
  border-radius: 22px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
  transition: transform 0.3s var(--ease-spring);
  will-change: transform;
}
.bind-logo img:hover { transform: scale(1.05) rotate(-2deg); }
.bind-logo h1 {
  font-size: 26px;
  margin-top: 14px;
  font-weight: 800;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, #fff 0%, rgba(255, 255, 255, 0.8) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.bind-logo p { margin-top: 10px; font-size: 13px; color: rgba(255, 255, 255, 0.6); line-height: 1.8; }

.bind-status {
  width: 100%;
  min-height: 42px;
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  font-size: 13px;
  text-align: center;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.85);
  word-break: break-all;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.3s ease;
}
.bind-status.error { background: rgba(239, 68, 68, 0.2); border-color: rgba(239, 68, 68, 0.3); color: #fecaca; }
.bind-status.ok { background: rgba(34, 197, 94, 0.15); border-color: rgba(34, 197, 94, 0.25); color: #bbf7d0; }

.bind-card label { display: block; font-size: 12.5px; color: rgba(255, 255, 255, 0.65); margin-bottom: 8px; font-weight: 500; }
.bind-card input[type="text"] {
  width: 100%;
  padding: 13px 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  font-size: 15px;
  outline: none;
  margin-bottom: 14px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.bind-card input[type="text"]:focus {
  border-color: var(--brand-3);
  box-shadow: 0 0 0 3px var(--brand-glow), 0 2px 8px rgba(0, 0, 0, 0.06);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-3) 100%);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 12px;
  box-shadow: var(--shadow-brand);
  transition: all 0.2s var(--ease-out);
  position: relative;
  overflow: hidden;
  will-change: transform;
}
.btn-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
  pointer-events: none;
}
.btn-primary:active { transform: scale(0.97); box-shadow: var(--shadow-brand-lg); }

.btn-ghost {
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.88);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  will-change: transform;
}
.btn-ghost:active { background: rgba(255, 255, 255, 0.14); transform: scale(0.98); }

.phone-name-box, .phone-avatar-box { margin-bottom: 16px; }
.phone-avatar-row { display: flex; align-items: center; gap: 12px; }
.avatar-preview {
  width: 56px; height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}
.avatar-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}
.avatar-pick:active { background: rgba(255, 255, 255, 0.18); }
.avatar-clear {
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fca5a5;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.avatar-clear:active { background: rgba(239, 68, 68, 0.15); }
.bind-tip {
  margin-top: 28px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  text-align: center;
  line-height: 1.8;
  max-width: 340px;
  position: relative;
  z-index: 1;
}

/* ==================== Main Page (WeChat-inspired) ==================== */
.main-page { background: var(--bg); }

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + var(--safe-top)) 16px 12px;
  background: linear-gradient(135deg, var(--brand-deep) 0%, var(--brand-2) 100%);
  flex-shrink: 0;
  position: relative;
  z-index: 20;
}
.main-header::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
}
.main-header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.main-logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}
.main-title-box { min-width: 0; }
.main-title { font-size: 20px; font-weight: 800; color: #fff; letter-spacing: -0.2px; line-height: 1.2; }
.main-sub {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.65);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.main-sub.ok { color: #86EFAC; }

.top-more-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.14);
  font-size: 22px;
  font-weight: 300;
  color: #fff;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease-out);
  backdrop-filter: blur(8px);
}
.top-more-btn:active { transform: rotate(90deg) scale(0.9); background: rgba(255, 255, 255, 0.28); }

/* Dropdown Menu */
.menu-mask { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 40; animation: fadeIn 0.2s ease; will-change: opacity; }
.top-menu {
  position: absolute;
  top: calc(66px + var(--safe-top));
  right: 14px;
  width: 244px;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 41;
  padding: 8px;
  animation: popIn 0.22s var(--ease-spring);
  transform-origin: top right;
  border: 1px solid rgba(0, 0, 0, 0.04);
  will-change: transform, opacity;
}
.top-menu::before {
  content: "";
  position: absolute;
  top: -7px;
  right: 22px;
  width: 14px;
  height: 14px;
  background: var(--card);
  transform: rotate(45deg);
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-right: none;
  border-bottom: none;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease;
}
.menu-item:active { background: var(--bg); }
.menu-item.danger .menu-title { color: var(--danger); }
.menu-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--brand-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  transition: transform 0.2s var(--ease-spring);
}
.menu-item:active .menu-icon { transform: scale(0.9); }
.menu-item.danger .menu-icon { background: var(--danger-soft); }
.menu-text { min-width: 0; }
.menu-title { font-size: 14.5px; font-weight: 600; color: var(--text); }
.menu-desc { font-size: 11.5px; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* PC Switch Bar */
.pc-switch-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 4px;
  flex-shrink: 0;
}
.pc-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-width: 0;
  padding-bottom: 4px;
}
.pc-chips::-webkit-scrollbar { display: none; }
.pc-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: var(--radius-full);
  background: var(--card);
  border: 1px solid rgba(0, 0, 0, 0.06);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  max-width: 155px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: var(--shadow-xs);
}
.pc-chip .pc-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #D1D5DB;
  flex-shrink: 0;
  transition: background 0.3s ease;
}
.pc-chip .pc-dot.on { background: var(--ok); box-shadow: 0 0 6px rgba(34, 197, 94, 0.5); }
.pc-chip.active {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-3) 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-brand);
}
.pc-chip.active .pc-dot { background: #A7F3D0; }
.pc-chip .pc-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-width: 18px;
  height: 16px;
  padding: 0 4px;
  border-radius: 5px;
  background: linear-gradient(135deg, #F97316, #EA580C);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
}
.pc-chip.active .pc-primary { background: rgba(255, 255, 255, 0.22); }
.pc-chip .pc-badge {
  position: absolute;
  top: -5px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
}
.pc-chip:active { transform: scale(0.95); }
.pc-add-chip {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1.5px dashed var(--brand);
  background: var(--brand-light);
  color: var(--brand);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease-spring);
}
.pc-add-chip:active { transform: scale(0.88); background: rgba(15, 168, 120, 0.15); }

/* Search */
.search-box { padding: 8px 14px 6px; flex-shrink: 0; }
.search-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  transition: all 0.2s ease;
}
.search-inner:focus-within {
  background: var(--card);
  box-shadow: 0 0 0 2px var(--brand-glow);
}
.search-icon { font-size: 14px; opacity: 0.4; }
.search-inner input { flex: 1; border: none; outline: none; font-size: 14.5px; background: transparent; color: var(--text); }
.search-inner input::placeholder { color: var(--text-3); }

/* Contact List */
.contact-scroll { flex: 1; overflow-y: auto; padding: 6px 0 14px; -webkit-overflow-scrolling: touch; contain: layout style; }
.contact-list { display: block; }
.sec-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  padding: 12px 16px 5px;
  letter-spacing: 0.2px;
}
.sec-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 12px;
}
.sec-title-row .sec-title { flex: 1; min-width: 0; }
.dev-refresh {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--brand);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s var(--ease-out);
}
.dev-refresh:active { transform: rotate(180deg); }
.dev-refresh.spinning { animation: spin 0.7s linear infinite; }

.group-title {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-3);
  padding: 10px 16px 4px;
}

.wechat-cell,
.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  padding: 13px 16px;
  cursor: pointer;
  transition: background 0.15s ease;
  position: relative;
}
.wechat-cell:active, .contact-item:active { background: var(--bg); }
.contact-item + .contact-item { border-top: 0.5px solid rgba(0, 0, 0, 0.04); }
.wechat-cell { border-bottom: 0.5px solid rgba(0, 0, 0, 0.04); }

.contact-avatar {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
  position: relative;
  box-shadow: inset 0 -2px 6px rgba(0, 0, 0, 0.12);
}
.contact-avatar .online-dot {
  position: absolute;
  right: -2px;
  bottom: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ok);
  border: 2.5px solid #fff;
  box-shadow: 0 0 4px rgba(34, 197, 94, 0.4);
}

.contact-info { flex: 1; min-width: 0; }
.contact-row1, .contact-row2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.contact-name { font-size: 16px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-time { font-size: 11.5px; color: var(--text-3); flex-shrink: 0; }
.contact-row2 { margin-top: 4px; }
.contact-preview { font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.contact-preview.self { color: var(--text-2); }
.contact-os {
  flex-shrink: 0;
  font-size: 10.5px;
  color: var(--text-3);
  background: var(--bg);
  border-radius: 5px;
  padding: 2px 6px;
  font-weight: 500;
}
.contact-badge {
  flex-shrink: 0;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
}

.contact-empty {
  text-align: center;
  color: var(--text-3);
  font-size: 13.5px;
  padding: 60px 20px;
  line-height: 2;
}

/* Tab Bar */
.tab-bar {
  display: flex;
  flex-shrink: 0;
  border-top: 0.5px solid rgba(0, 0, 0, 0.06);
  background: var(--card);
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.03);
}
.tab-item {
  flex: 1;
  text-align: center;
  padding: 8px 0 6px;
  font-size: 11px;
  color: var(--text-3);
  cursor: pointer;
  transition: color 0.2s ease;
  font-weight: 500;
}
.tab-ico { display: block; font-size: 20px; margin-bottom: 2px; transition: transform 0.2s var(--ease-spring); will-change: transform; }
.tab-item.active { color: var(--brand); font-weight: 700; }
.tab-item.active .tab-ico { transform: scale(1.1); }

/* ==================== Sub Headers ==================== */
.sub-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: calc(14px + var(--safe-top)) 12px 12px;
  background: linear-gradient(135deg, var(--brand-deep) 0%, var(--brand-2) 100%);
  flex-shrink: 0;
  position: relative;
  z-index: 20;
}
.header-back {
  border: none;
  background: transparent;
  color: #fff;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px 6px 2px;
  margin-left: -6px;
  transition: opacity 0.15s ease;
}
.header-back:active { opacity: 0.5; }
.sub-head-main { flex: 1; min-width: 0; }
.sub-head-title { font-size: 17px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub-head-sub { font-size: 11.5px; color: rgba(255, 255, 255, 0.65); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ==================== Chat Page ==================== */
.chat-page { background: var(--bg); }
.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(14px + var(--safe-top)) 12px 12px;
  background: linear-gradient(135deg, var(--brand-deep) 0%, var(--brand-2) 100%);
  flex-shrink: 0;
  position: relative;
  z-index: 25;
}
.chat-head-main { flex: 1; min-width: 0; }
.chat-head-name { font-size: 17px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head-sub { font-size: 11.5px; color: rgba(255, 255, 255, 0.65); margin-top: 1px; }
.header-more {
  width: 38px; height: 38px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.header-more:active { background: rgba(255, 255, 255, 0.28); transform: scale(0.92); }

/* Chat More Menu */
.chat-more-menu {
  position: absolute;
  top: calc(64px + var(--safe-top));
  right: 12px;
  width: 220px;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 45;
  padding: 8px;
  animation: popIn 0.22s var(--ease-spring);
  transform-origin: top right;
  border: 1px solid rgba(0, 0, 0, 0.04);
}
.chat-more-menu::before {
  content: "";
  position: absolute;
  top: -7px;
  right: 24px;
  width: 14px; height: 14px;
  background: var(--card);
  transform: rotate(45deg);
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-right: none;
  border-bottom: none;
}

.view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.msg-area {
  flex: 1;
  overflow-y: auto;
  padding: 14px 13px 10px;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  contain: layout style;
}
.empty-chat { text-align: center; color: var(--text-3); font-size: 14px; padding-top: 90px; line-height: 2; }

/* Time Separator */
.msg-sep {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-3);
  margin: 12px 0 16px;
  background: rgba(255, 255, 255, 0.8);
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
  padding: 4px 14px;
  border-radius: var(--radius-full);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-weight: 500;
}

/* Chat Bubbles */
.msg-row { display: flex; margin-bottom: 16px; align-items: flex-start; }
.msg-row.self { justify-content: flex-end; }
.msg-avatar {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #DBEAFE, #BFDBFE);
  color: #2563EB;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
  margin-right: 10px;
  box-shadow: var(--shadow-xs);
}
.msg-row.self .msg-avatar {
  margin-right: 0;
  margin-left: 10px;
  order: 2;
  background: linear-gradient(135deg, #D1FAE5, #A7F3D0);
  color: var(--brand);
}
.msg-body { max-width: 74%; min-width: 0; }
.msg-name { font-size: 11.5px; color: var(--text-3); margin-bottom: 4px; padding: 0 3px; font-weight: 500; }
.msg-row.self .msg-name { text-align: right; }
.bubble {
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--card);
  font-size: 15.5px;
  will-change: transform;
  line-height: 1.55;
  word-break: break-word;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.msg-row.self .bubble {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  border-top-right-radius: 4px;
  box-shadow: var(--shadow-brand);
}
.msg-row.other .bubble { border-top-left-radius: 4px; }
.msg-time { font-size: 11px; color: var(--text-3); margin-top: 4px; padding: 0 3px; }
.msg-row.self .msg-time { text-align: right; }
.msg-state { font-size: 11px; margin-top: 3px; padding: 0 3px; text-align: right; font-weight: 500; }
.msg-state.received { color: var(--ok); }
.msg-state.failed { color: var(--danger); }
.msg-state.sending { color: var(--warn); }
.msg-state.sent { color: var(--text-3); }

/* Rich Text */
.bubble .code-block {
  background: #1E293B;
  color: #E2E8F0;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 8px 0;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-all;
}
.bubble pre.inline-code {
  display: inline;
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 5px;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 13px;
  color: #DC2626;
}
.msg-row.self .bubble pre.inline-code { background: rgba(255, 255, 255, 0.15); color: #FDE68A; }
.msg-row.self .bubble a { color: #D1FAE5; }
.bubble img.emoji-img { width: 18px; height: 18px; vertical-align: -3px; }

/* File / Voice / Image Cards */
.file-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
  min-width: 170px;
}
.msg-row.self .file-card { background: rgba(255, 255, 255, 0.92); }
.file-icon { font-size: 26px; }
.file-name { font-weight: 600; word-break: break-all; font-size: 13.5px; }
.file-meta { color: var(--text-3); font-size: 11px; margin-top: 3px; }
.file-progress { width: 100%; height: 5px; background: rgba(0,0,0,0.08); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.msg-row.self .file-progress { background: rgba(0,0,0,0.1); }
.file-progress-bar { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.3s ease; }
.file-progress-text { color: var(--text-3); font-size: 10px; margin-top: 3px; }
.voice-card {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 100px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: var(--shadow-sm);
  color: var(--text);
}
.msg-row.self .voice-card {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
}
.voice-icon { font-size: 18px; }
.voice-dur { font-size: 14px; font-weight: 600; }
.voice-tip { font-size: 10px; color: var(--text-3); }
.msg-row.self .voice-tip { color: rgba(255, 255, 255, 0.7); }
.voice-sent { font-size: 10px; color: #D1FAE5; }
.image-card { border-radius: 12px; overflow: hidden; background: var(--card); box-shadow: var(--shadow-sm); position: relative; }
.image-thumb { display: block; max-width: 210px; max-height: 270px; object-fit: cover; }
.image-thumb.no-preview { opacity: 0.5; width: 130px; height: 130px; background: var(--bg); }
.image-sent { position: absolute; right: 8px; bottom: 8px; font-size: 10px; color: #fff; background: rgba(0, 0, 0, 0.5); padding: 3px 8px; border-radius: 10px; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }

.msg-source { font-size: 10.5px; color: var(--text-3); margin-top: 3px; }
.msg-row.self .msg-source { text-align: right; }
.source-avatar { width: 14px; height: 14px; border-radius: 50%; object-fit: cover; vertical-align: -2px; margin-right: 3px; }

/* Typing Indicator */
.typing-hint { font-size: 12.5px; color: var(--brand); padding: 5px 5px 0; font-weight: 500; }
.typing-dots { display: inline-flex; gap: 3px; margin-right: 5px; vertical-align: middle; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--brand); animation: tb 1.2s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes tb { 0%,60%,100% { transform: translateY(0); opacity: 0.35; } 30% { transform: translateY(-4px); opacity: 1; } }

/* Input Bar */
.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: var(--card);
  border-top: 0.5px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}
.input-bar textarea {
  flex: 1;
  border: none;
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 15.5px;
  resize: none;
  outline: none;
  max-height: 100px;
  font-family: inherit;
  background: var(--bg);
  transition: all 0.2s ease;
}
.input-bar textarea:focus { background: var(--bg-warm); box-shadow: 0 0 0 2px var(--brand-glow); }
.btn-send {
  border: none;
  background: linear-gradient(135deg, var(--brand), var(--brand-3));
  color: #fff;
  padding: 10px 20px;
  border-radius: 22px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: var(--shadow-brand);
  transition: all 0.2s var(--ease-out);
  will-change: transform;
}
.btn-send:active { transform: scale(0.94); }
.btn-send:disabled { background: #CBD5E1; box-shadow: none; }

.btn-round {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border: none;
  border-radius: 50%;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  transition: transform 0.15s var(--ease-spring);
}
.btn-round:active { transform: scale(0.88); }
.btn-round.plus { font-size: 24px; font-weight: 600; color: var(--text-2); }
.btn-voice {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  color: var(--text-2);
  font-size: 19px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  transition: all 0.2s var(--ease-spring);
}
.btn-voice:active { transform: scale(0.9); }
.btn-voice.rec {
  background: var(--danger);
  color: #fff;
  animation: rec-pulse 1s ease-in-out infinite;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
}
@keyframes rec-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }

.rec-hint {
  position: fixed;
  left: 50%;
  top: 42%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  font-size: 15px;
  padding: 14px 24px;
  border-radius: var(--radius-lg);
  z-index: 60;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow-xl);
  font-weight: 500;
}

/* Emoji Panel */
.emoji-panel {
  background: var(--bg-warm);
  border-top: 0.5px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
  max-height: 40vh;
  overflow-y: auto;
  padding: 10px 8px calc(10px + var(--safe-bottom));
}
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-cell { font-size: 26px; text-align: center; padding: 7px 0; border-radius: 10px; cursor: pointer; transition: all 0.15s ease; }
.emoji-cell:active { background: rgba(0, 0, 0, 0.06); transform: scale(0.9); }

/* More Panel */
.more-panel2 {
  background: var(--bg-warm);
  border-top: 0.5px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
  padding: 16px 16px calc(16px + var(--safe-bottom));
}
.more-grid { display: flex; gap: 24px; }
.more-grid-item { text-align: center; cursor: pointer; }
.more-grid-icon {
  width: 56px; height: 56px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto;
  transition: all 0.2s var(--ease-spring);
}
.more-grid-item:active .more-grid-icon { transform: scale(0.88); box-shadow: var(--shadow-xs); }
.more-grid-label { font-size: 12px; color: var(--text-2); margin-top: 7px; font-weight: 500; }

/* ==================== Message Long-Press Menu ==================== */
.msg-menu-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 110;
  animation: fadeIn 0.18s ease;
  will-change: opacity;
}
.msg-menu {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--card);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  z-index: 120;
  padding: 8px 0 calc(12px + var(--safe-bottom));
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.15);
  animation: slideUp 0.28s var(--ease-out);
  will-change: transform;
}
.msg-menu-title {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  padding: 10px 20px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.msg-menu-item {
  padding: 15px 20px;
  font-size: 15.5px;
  font-weight: 500;
  text-align: center;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.04);
  cursor: pointer;
  transition: background 0.12s ease;
}
.msg-menu-item:active { background: var(--bg); }
.msg-menu-item:last-child { border-bottom: none; }
.msg-menu-item.danger { color: var(--danger); font-weight: 600; }
.msg-menu-item.hidden-item { display: none; }

/* ==================== Forward Panel ==================== */
.forward-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: 26%;
  background: var(--card);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  z-index: 130;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.15);
  animation: slideUp 0.28s var(--ease-out);
  will-change: transform;
}
.forward-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  font-size: 16px;
  font-weight: 700;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}
.forward-list { flex: 1; overflow-y: auto; padding: 12px 16px; -webkit-overflow-scrolling: touch; }
.forward-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.12s ease;
}
.forward-item:active { background: var(--bg); }
.forward-avatar {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: inset 0 -3px 8px rgba(0, 0, 0, 0.12);
}
.forward-name { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.forward-pc-tag {
  flex-shrink: 0;
  font-size: 10.5px;
  color: #fff;
  background: var(--brand);
  border-radius: 7px;
  padding: 2px 8px;
  font-weight: 600;
}

/* ==================== Tools Page ==================== */
.refresh-btn {
  width: 38px; height: 38px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease-spring);
}
.refresh-btn:active { background: rgba(255, 255, 255, 0.28); transform: scale(0.9); }
.refresh-btn.spin { animation: spin 0.5s ease; }
.refresh-btn.stop { background: rgba(239, 68, 68, 0.5); font-size: 16px; }
.refresh-btn.stop:active { background: rgba(239, 68, 68, 0.7); }

/* Blocks Panel */
.blocks-panel {
  position: absolute;
  top: calc(64px + var(--safe-top));
  left: 12px;
  right: 12px;
  bottom: 12px;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: popIn 0.24s var(--ease-spring);
  border: 1px solid rgba(0, 0, 0, 0.04);
  will-change: transform, opacity;
}
.blocks-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  font-weight: 700;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.06);
}
.icon-btn { border: none; background: var(--bg); color: var(--text-2); width: 32px; height: 32px; border-radius: 50%; font-size: 14px; cursor: pointer; transition: all 0.15s ease; }
.icon-btn:active { background: rgba(0, 0, 0, 0.08); transform: scale(0.9); }
.blocks-list { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.blocks-empty { text-align: center; color: var(--text-3); padding: 40px 0; font-size: 13px; }
.block-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--danger-soft);
  border: 1px solid rgba(239, 68, 68, 0.15);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.block-info { min-width: 0; }
.block-name { font-size: 13.5px; font-weight: 600; color: #7F1D1D; word-break: break-all; }
.block-reason { font-size: 12px; color: #991B1B; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.block-restore { flex-shrink: 0; border: none; background: var(--danger); color: #fff; border-radius: var(--radius-sm); padding: 7px 15px; font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.15s ease; }
.block-restore:active { transform: scale(0.94); }

/* ==================== Tools List Page ==================== */
.tools-page { background: var(--bg); }
.tools-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px calc(22px + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  contain: layout style;
}

/* Pull Refresh */
.pull-refresh {
  height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-3);
  font-size: 12.5px;
  font-weight: 500;
  -webkit-user-select: none;
  user-select: none;
  transition: height 0.25s var(--ease-out);
}
.pull-refresh.tracking { transition: none; }
.pull-refresh .pull-icon {
  display: inline-block;
  font-size: 15px;
  transition: transform 0.25s var(--ease-spring);
}
.pull-refresh.ready .pull-icon { transform: rotate(180deg); }
.pull-refresh.loading .pull-icon { animation: spin 0.8s linear infinite; }

.tools-summary { display: flex; gap: 12px; margin-bottom: 18px; }
.summary-card {
  flex: 1;
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  will-change: transform;
}
.summary-num { font-size: 24px; font-weight: 800; color: var(--brand); }
.summary-card .summary-label { font-size: 12px; color: var(--text-3); margin-top: 3px; font-weight: 500; }
.summary-card.off .summary-num { color: var(--text-3); }

.tools-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }

.tool-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
  border-left: 4px solid transparent;
  will-change: transform;
}
.tool-card:active { transform: scale(0.985); }
.tool-card.running { border-left-color: var(--ok); }
.tool-card.stopped { border-left-color: #D1D5DB; opacity: 0.75; }
.tool-card-row1 { display: flex; align-items: center; gap: 10px; }
.tool-card-name { font-size: 15.5px; font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-card-state { font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 10px; flex-shrink: 0; }
.tool-card-state.run { background: var(--ok-soft); color: #166534; }
.tool-card-state.stop { background: var(--bg); color: var(--text-3); }
.tool-card-row2 { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.tool-tag {
  font-size: 11.5px;
  color: var(--text-2);
  background: var(--bg);
  border-radius: 8px;
  padding: 3px 9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  font-weight: 500;
}
.tool-card .tool-arrow { margin-left: auto; color: var(--text-3); font-size: 18px; flex-shrink: 0; }

/* Swipe Actions */
.tool-swipe { position: relative; overflow: hidden; border-radius: var(--radius); }
.tool-swipe-actions {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  display: flex;
  align-items: stretch;
}
.tool-swipe-actions button {
  border: none;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 0 18px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tool-swipe-actions .act-archive { background: #3B82F6; }
.tool-swipe-actions .act-delete { background: #EF4444; }
.tool-swipe-body {
  position: relative;
  z-index: 1;
  background: var(--card);
  border-radius: var(--radius);
  transition: transform 0.22s var(--ease-out);
  touch-action: pan-y;
  will-change: transform;
}

/* Archived */
.archived-filter { display: flex; gap: 10px; margin-bottom: 14px; }
.archived-search-input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--card);
  outline: none;
  transition: all 0.2s ease;
}
.archived-search-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.archived-tool-select {
  flex-shrink: 0;
  padding: 10px 14px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--card);
  color: var(--text);
  outline: none;
  min-width: 105px;
  transition: border-color 0.2s ease;
}
.archived-tool-select:focus { border-color: var(--brand); }
.archived-card { border-left-color: #8B5CF6 !important; }
.archived-card.selected { background: #FAF5FF; border-left-color: #7C3AED !important; }
.archived-batch-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; margin-bottom: 6px; }
.archived-check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  font-weight: 500;
}
.archived-check-label input[type="checkbox"] { width: 17px; height: 17px; accent-color: #7C3AED; }
.archived-check { width: 17px; height: 17px; accent-color: #7C3AED; flex-shrink: 0; margin-right: 4px; }
.archived-batch-actions { display: flex; align-items: center; gap: 10px; }
.archived-batch-count { font-size: 12.5px; color: #7C3AED; font-weight: 700; }
.archived-del-btn {
  flex-shrink: 0;
  border: none;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}
.archived-del-btn:active { transform: scale(0.92); }
.tool-restore-btn {
  flex-shrink: 0;
  border: none;
  background: #8B5CF6;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}
.tool-restore-btn:active { transform: scale(0.92); }

.tool-tag-run { font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 10px; flex-shrink: 0; }
.tool-tag-run.run { background: var(--ok-soft); color: #166534; }
.tool-tag-run.stop { background: var(--bg); color: var(--text-3); }
.tool-tag.loc { background: #EFF6FF; color: #2563EB; }

/* Session / Process */
.t-proc {
  margin: 10px 0 12px 36px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #1E293B;
}
.t-proc-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  cursor: pointer;
  user-select: none;
  background: #243349;
  transition: background 0.15s ease;
}
.t-proc-head:active { background: #2D3F57; }
.t-proc-ico { font-size: 14px; }
.t-proc-title { font-size: 12.5px; font-weight: 600; color: #CBD5E1; flex: 1; }
.t-proc-arrow { font-size: 13px; color: #94A3B8; transition: transform 0.2s var(--ease-spring); }
.t-proc:not(.open) .t-proc-arrow { transform: rotate(-90deg); }
.t-proc-body { display: none; }
.t-proc.open .t-proc-body { display: block; }
.t-proc-body pre {
  margin: 0;
  padding: 12px 14px;
  font-family: "SF Mono", Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #E2E8F0;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 270px;
  overflow-y: auto;
}

.t-feedback { display: flex; gap: 7px; margin-top: 6px; }
.t-fb-btn {
  border: none;
  background: #F1F5F9;
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
  transition: all 0.15s ease;
}
.t-fb-btn:active { transform: scale(0.92); }
.t-fb-btn.on { background: var(--brand); color: #fff; }

.msg-feedback { display: flex; gap: 7px; margin-top: 5px; }
.msg-fb-btn {
  border: none;
  background: rgba(255, 255, 255, 0.85);
  border: 0.5px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
  transition: all 0.15s ease;
}
.msg-fb-btn:active { transform: scale(0.92); }
.msg-fb-btn.on { background: var(--brand); border-color: transparent; color: #fff; }

/* Workspace → Task */
.tool-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 3px 5px;
  border-top: 0.5px solid rgba(0, 0, 0, 0.06);
  margin-top: 5px;
  background: var(--card);
  border-radius: var(--radius);
  will-change: transform;
}
.tool-head:first-child { border-top: none; margin-top: 0; padding-top: 7px; }
.tool-head-name { font-size: 16.5px; font-weight: 800; color: var(--text); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-head-state { font-size: 12px; font-weight: 600; flex-shrink: 0; }
.tool-head-state.run { color: var(--ok); }
.tool-head-state.stop { color: var(--text-3); }
.tool-ws {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 3px 5px;
  font-size: 13px;
  color: var(--text-2);
}
.tool-ws-ico { font-size: 14px; }
.tool-ws-name { font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-ws-count { font-size: 11.5px; color: var(--text-3); flex-shrink: 0; }
.tool-card.task { border-left-color: #3B82F6; padding: 12px 14px; }
.tools-empty {
  text-align: center;
  color: var(--text-3);
  font-size: 13.5px;
  padding: 28px 16px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  line-height: 1.8;
  margin-bottom: 10px;
}

.mon-start-btn {
  flex-shrink: 0;
  padding: 9px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--brand), var(--brand-3));
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-brand);
  transition: all 0.15s ease;
}
.mon-start-btn:active { transform: scale(0.96); }
.mon-start-btn:disabled { background: #CBD5E1; box-shadow: none; cursor: default; }

/* ==================== Tool Detail Page ==================== */
.tool-detail-page { background: #0B1220; }
.tool-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0 0;
  -webkit-overflow-scrolling: touch;
}
.tool-log {
  height: 100%;
  min-height: 200px;
  overflow-y: auto;
  margin: 0;
  padding: 14px 18px calc(18px + var(--safe-bottom));
  font-family: "SF Mono", Consolas, "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.7;
  color: #C9D6E3;
  background: #0B1220;
  white-space: pre-wrap;
  word-break: break-all;
}
.tool-log .t-tag { opacity: 0.8; font-weight: 600; }
.tool-log .t-user { color: #4ADE80; }
.tool-log .t-agent { color: #7DD3FC; }
.tool-log .t-tool { color: #FBBF24; }
.tool-input-row {
  display: flex;
  gap: 10px;
  padding: 12px 14px calc(12px + var(--safe-bottom));
  background: #0B1220;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.tool-input-row textarea {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: #101A2E;
  font-size: 13.5px;
  outline: none;
  color: #E8EEF5;
  resize: none;
  max-height: 100px;
  line-height: 1.4;
  font-family: inherit;
  transition: border-color 0.2s ease;
}
.tool-input-row textarea::placeholder { color: rgba(201, 214, 227, 0.4); }
.tool-input-row textarea:focus { border-color: var(--brand); }
.tool-input-row textarea:disabled { background: rgba(16, 26, 46, 0.5); color: rgba(201, 214, 227, 0.35); }
.tool-input-row .mon-start-btn { padding: 11px 20px; border-radius: var(--radius); }

/* ==================== Tools Add/Group ==================== */
.tools-add-pc {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 14px 16px 10px;
  padding: 13px 18px;
  border-radius: var(--radius);
  background: var(--brand-light);
  border: 1.5px dashed var(--brand);
  color: var(--brand);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.tools-add-pc:active { background: rgba(15, 168, 120, 0.15); transform: scale(0.98); }
.tools-add-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 17px;
  line-height: 1;
}
.tools-pc-group { margin: 0 16px; }
.tools-pc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 0 7px;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.06);
  margin-bottom: 5px;
}
.tools-pc-name { font-size: 13.5px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 7px; }
.tools-pc-online { font-size: 11.5px; color: var(--ok); font-weight: 600; }
.tools-pc-offline { font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.tools-pc-set-primary {
  font-size: 11.5px;
  color: var(--brand);
  font-weight: 600;
  cursor: pointer;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--brand-light);
  transition: all 0.15s ease;
}
.tools-pc-set-primary:active { background: rgba(15, 168, 120, 0.18); }
.pc-primary-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 15px;
  padding: 0 5px;
  border-radius: 4px;
  background: linear-gradient(135deg, #F97316, #EA580C);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 15px;
}
.tool-card-simple {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 16px;
  margin: 5px 0;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
  will-change: transform;
}
.tool-card-simple:active { transform: scale(0.98); }
.tool-card-left {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--brand-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 19px;
  transition: transform 0.2s var(--ease-spring);
}
.tool-card-simple:active .tool-card-left { transform: scale(0.9); }
.tool-card-mid { flex: 1; min-width: 0; }
.tool-card-name { font-size: 14.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-card-sub { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.tool-card-simple.running .tool-card-left { background: rgba(15, 168, 120, 0.12); }
.tools-empty-sm { padding: 12px 16px; font-size: 12.5px; color: var(--text-3); text-align: center; }

/* ==================== Scan Overlay ==================== */
.scan-overlay {
  position: fixed;
  inset: 0;
  background: #0A0F0D;
  z-index: 100;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.25s ease;
}
.scan-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(18px + var(--safe-top)) 20px 16px;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  position: relative;
  z-index: 3;
  background: rgba(10, 15, 13, 0.92);
}
.scan-head .icon-btn { background: rgba(255, 255, 255, 0.14); color: #fff; }
.scan-body { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 0 24px; position: relative; overflow: hidden; }
.scan-frame-wrap { display: flex; flex-direction: column; align-items: center; margin-top: 28px; position: relative; z-index: 2; }
.scan-frame {
  position: relative;
  width: 240px;
  height: 240px;
  border-radius: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.55), 0 0 60px rgba(15, 168, 120, 0.4);
  overflow: hidden;
  background: transparent;
}
.scan-frame::before, .scan-frame::after {
  content: "";
  position: absolute;
  width: 36px;
  height: 36px;
  border: 4px solid var(--brand-3);
}
.scan-frame::before { top: -2px; left: -2px; border-right: none; border-bottom: none; border-top-left-radius: 18px; }
.scan-frame::after { bottom: -2px; right: -2px; border-left: none; border-top: none; border-bottom-right-radius: 18px; }
.scan-line {
  position: absolute;
  left: 10px;
  right: 10px;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, transparent, var(--brand-3), transparent);
  animation: scanMove 2.4s ease-in-out infinite;
  box-shadow: 0 0 14px rgba(15, 168, 120, 0.8);
  will-change: transform;
}
@keyframes scanMove { 0% { top: 12px; } 50% { top: calc(100% - 16px); } 100% { top: 12px; } }
.scan-tip { color: rgba(255, 255, 255, 0.7); font-size: 13.5px; margin-top: 28px; font-weight: 500; }
.scan-video {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
  background: #000;
  z-index: 1;
}

.scan-body .btn-ghost, .scan-body .manual-box { position: relative; z-index: 3; }
.scan-body .btn-ghost { max-width: 330px; margin-top: 20px; }
.scan-body .manual-box { width: 100%; max-width: 330px; margin-top: 16px; }
.scan-body .manual-box input { background: rgba(255, 255, 255, 0.95); color: #111; border: none; }

/* 扫码成功勾选动画 */
.scan-success {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 15, 13, 0.85);
  animation: fadeIn 0.2s ease;
}
.scan-success-circle {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--brand-3, #0fa878);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: scanPopIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 40px rgba(15, 168, 120, 0.6);
}
.scan-success-check {
  width: 48px;
  height: 48px;
  stroke: #fff;
  stroke-width: 4;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 60;
  stroke-dashoffset: 60;
  animation: scanDraw 0.4s 0.2s ease forwards;
}
.scan-success-text {
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  margin-top: 20px;
  opacity: 0;
  animation: fadeInUp 0.3s 0.35s ease forwards;
}
@keyframes scanPopIn { 0% { transform: scale(0); } 100% { transform: scale(1); } }
@keyframes scanDraw { to { stroke-dashoffset: 0; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ==================== Dialog ==================== */
.ui-dialog { position: fixed; inset: 0; z-index: 300; }
.ui-dialog-mask { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fadeIn 0.2s ease; will-change: opacity; }
.ui-dialog-card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.88);
  width: min(310px, 82vw);
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 26px 22px 18px;
  box-shadow: var(--shadow-xl);
  opacity: 0;
  transition: transform 0.25s var(--ease-spring), opacity 0.2s ease;
  will-change: transform, opacity;
}
.ui-dialog-card.show { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.ui-dialog-title { font-size: 17px; font-weight: 700; text-align: center; color: var(--text); }
.ui-dialog-msg { font-size: 14px; color: var(--text-2); text-align: center; margin-top: 12px; line-height: 1.65; white-space: pre-line; word-break: break-all; }
.ui-dialog-input {
  width: 100%;
  margin-top: 16px;
  padding: 11px 14px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius);
  font-size: 14.5px;
  outline: none;
  color: var(--text);
  background: var(--bg);
  transition: all 0.2s ease;
}
.ui-dialog-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); background: var(--card); }
.ui-dialog-btns { display: flex; gap: 10px; margin-top: 22px; }
.ui-dialog-btn {
  flex: 1;
  padding: 11px 0;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg);
  color: var(--text);
  transition: all 0.15s ease;
}
.ui-dialog-btn:active { transform: scale(0.96); background: rgba(0, 0, 0, 0.06); }
.ui-dialog-btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-3)); color: #fff; box-shadow: var(--shadow-brand); }
.ui-dialog-btn.danger { background: var(--danger-soft); color: var(--danger); }
.ui-dialog-btns.list { flex-direction: column; gap: 8px; margin-top: 20px; }
.ui-dialog-btns.list .ui-dialog-btn { text-align: center; }
.ui-dialog-btns.list .ui-dialog-btn.cancel { background: var(--bg); color: var(--text-3); }

/* ==================== Toast ==================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(95px + var(--safe-bottom));
  transform: translateX(-50%) translateY(10px);
  background: rgba(20, 30, 26, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  padding: 11px 22px;
  border-radius: var(--radius-full);
  z-index: 200;
  max-width: 78%;
  text-align: center;
  box-shadow: var(--shadow-xl);
  animation: toastIn 0.25s var(--ease-spring) forwards;
  pointer-events: none;
  will-change: transform, opacity;
}
.toast.error { background: rgba(220, 38, 38, 0.92); }
.toast.out { animation: toastOut 0.25s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(16px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(-50%) translateY(12px); } }
