/* 手机与窄屏：安全区、触控、单列、避免横向滚动 */

button, a, select, label { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
body {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.nav-scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 180;
  background: var(--scrim);
  border: 0;
  padding: 0;
  margin: 0;
}
.topbar.nav-open ~ .nav-scrim { display: block; }

@media (max-width: 800px) {
  .shell,
  .site-foot,
  .shell.bmc-wide {
    width: min(100%, calc(100% - 28px));
  }
  .topbar {
    padding-top: env(safe-area-inset-top);
    background: var(--bg);
  }
  .topbar-inner { padding: 8px 0; gap: 8px; }
  .brand small { display: none; }
  .brand strong { font-size: 14px !important; }
  .nav-links {
    left: 14px;
    right: 14px;
    top: calc(52px + env(safe-area-inset-top));
    min-width: 0;
    width: auto;
  }
  .nav-links .nav-btn,
  .nav-links .nav-ghost,
  .nav-links .theme-select-label {
    min-height: 44px;
    height: auto;
    width: 100%;
    justify-content: flex-start;
  }

  .hero-landing { padding: 28px 0 20px; }
  .hero-landing h1 { font-size: clamp(26px, 8vw, 34px); }
  .hero-actions { flex-direction: column; width: 100%; }
  .hero-actions .tonal,
  .hero-actions .outlined { width: 100%; }
  .starters { width: 100%; }
  .starter { width: 100%; justify-content: center; min-height: 44px; }
  .product-card { padding: 20px; }
  .preview { padding: 20px; }
  .preview-head { flex-direction: column; }

  .dock { padding: 8px 0 calc(20px + env(safe-area-inset-bottom)); }
  .composer {
    max-width: none;
    border-radius: 22px;
  }
  .composer input,
  .composer textarea,
  #homePrompt,
  .field input,
  .field textarea,
  .field select {
    font-size: 16px;
  }

  .workspace { padding: 16px 0 calc(28px + env(safe-area-inset-bottom)); }
  .workspace-head h2 { font-size: 24px; margin-top: 6px; }
  .workspace-head .flex { flex-wrap: wrap; width: 100%; }
  .mode-pill { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .surface { padding: 16px; border-radius: 16px; }
  .actions { flex-direction: column; align-items: stretch; }
  .actions .tonal,
  .actions .primary-btn,
  .actions .ghost-btn,
  .actions .outlined { width: 100%; }

  .chat { min-height: 0; }
  .messages {
    min-height: 220px;
    max-height: min(52dvh, 420px);
  }
  .chat .composer {
    position: sticky;
    bottom: env(safe-area-inset-bottom);
    z-index: 4;
    background: var(--panel);
  }
  .progress-aside { order: 2; }
  .md-table-wrap,
  .report-board { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .bubble-md table { min-width: 480px; }

  .canvas-hero-title { gap: 10px; }
  .canvas-mark { width: 40px; height: 40px; font-size: 18px; }
  .canvas-complete { min-width: 0; width: 100%; }
  .canvas-profile .actions { justify-content: stretch; }
  .q-card { padding: 14px; }
  .q-card-actions { width: 100%; }
  .q-card-actions .ghost-btn,
  .q-card-actions .primary-btn { flex: 1; min-height: 40px; justify-content: center; }
  .canvas-step-nav {
    position: sticky;
    bottom: 0;
    z-index: 6;
    flex-direction: column-reverse;
    margin: 12px -4px 0;
    padding: 12px 4px calc(10px + env(safe-area-inset-bottom));
    background: var(--bg);
    box-shadow: 0 -12px 20px var(--bg);
  }
  .canvas-step-nav .ghost-btn,
  .canvas-step-nav .primary-btn { width: 100%; min-height: 44px; }
  .gap-side {
    position: static;
    max-height: none;
  }
  .bmc-head-actions { justify-content: stretch; }
  .bmc-head-actions .ghost-btn,
  .bmc-head-actions .primary-btn { flex: 1 1 calc(50% - 8px); justify-content: center; min-height: 40px; }
  .bmc-nav { flex-direction: column; }
  .bmc-nav .ghost-btn { width: 100%; }
  .bmc-cell { min-height: 120px; }
  .bmc-board { gap: 10px; }
  .chat .text-xs { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  svg { max-width: 100%; height: auto; }
  .diag-card-head { flex-wrap: wrap; }

  .site-foot {
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
    gap: 6px;
  }
}

@media (max-width: 480px) {
  .hero-lead { font-size: 14px; }
  .workspace-head .eyebrow { letter-spacing: 0.04em; font-size: 11px; }
}
