/* 移动端与 iPhone 优化 */
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body { overflow-x: hidden; padding-bottom: env(safe-area-inset-bottom); }
button, input, textarea { touch-action: manipulation; }

@media (max-width: 760px) {
  .shell { width: 100%; padding: max(16px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 24px max(14px, env(safe-area-inset-left)); }
  .topbar { align-items: flex-start; gap: 12px; }
  .brand { min-width: 0; }
  .brand-mark { width: 36px; height: 36px; flex: none; }
  h1 { font-size: 17px; white-space: nowrap; }
  .top-actions { gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
  .connection { order: 3; width: 100%; justify-content: flex-end; font-size: 11px; }
  .icon-btn, .theme-btn { min-width: 42px; min-height: 42px; }
  .theme-btn { min-width: 58px; }
  .welcome { padding: 38px 0 24px; gap: 20px; }
  h2 { font-size: clamp(24px, 7vw, 30px); }
  .welcome p { font-size: 12px; line-height: 1.65; }
  .welcome .primary { width: 100%; min-height: 46px; }
  .profile { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 10px 12px; padding: 16px; }
  .profile-copy { min-width: 0; }
  .profile-copy h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .account-stats { grid-column: 1 / -1; width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 4px 0 0; }
  .account-stats div { text-align: center; }
  .account-stats b { font-size: 16px; }
  .profile-status { grid-column: 1 / -1; justify-content: center; padding-top: 8px; border-top: 1px solid var(--line); }
  .metrics { gap: 10px; margin-top: 10px; }
  .metric { padding: 16px; }
  .metric strong { font-size: 30px; }
  .periods { margin-top: 10px; padding-bottom: 2px; scrollbar-width: none; }
  .periods::-webkit-scrollbar { display: none; }
  .period, .chart-range { min-height: 40px; white-space: nowrap; }
  .chart-card, .messages-card, .activity-card { padding: 16px; }
  .section-head { gap: 10px; }
  .section-head h3 { font-size: 16px; }
  .chart-controls { overflow-x: auto; flex: none; }
  .chart-wrap { height: 190px; margin-top: 12px; }
  .grid { gap: 10px; margin-top: 10px; }
  .messages-card, .activity-card { min-height: 280px; }
  .messages, .activity { max-height: 280px; }
  footer { line-height: 1.5; word-break: break-word; }
  .settings-panel { width: 100%; padding: max(20px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); }
  .settings-panel h2 { font-size: 22px; }
  textarea, input { font-size: 16px; }
  .settings-actions { flex-direction: column; }
  .settings-actions button { width: 100%; min-height: 46px; }
  .toast { bottom: max(20px, env(safe-area-inset-bottom)); width: max-content; max-width: calc(100vw - 32px); text-align: center; }
}

@media (max-width: 380px) {
  .shell { padding-left: 11px; padding-right: 11px; }
  .brand { gap: 8px; }
  .brand-mark { width: 32px; height: 32px; }
  h1 { font-size: 15px; }
  .eyebrow { font-size: 9px; letter-spacing: .1em; }
  .top-actions { gap: 4px; }
  .icon-btn, .theme-btn { min-width: 38px; min-height: 38px; }
}
