/* Shared constraints for content and controls, loaded after page styles. */
img, video, canvas { max-width: 100%; }
img { height: auto; }
input, textarea, select { box-sizing: border-box; max-width: 100%; }
textarea { resize: vertical; }
.page { min-width: 0; overflow-wrap: anywhere; }
.page pre { max-width: 100%; overflow-x: auto; }
.pack-detail-image { display: block; width: 100%; max-width: 560px; height: auto; }
.resources-grid, .knowledge-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}
.resource-card, .knowledge-card { min-width: 0; overflow-wrap: anywhere; }
.table-scroll { max-width: 100%; overflow-x: auto; }

@media (max-width: 768px) {
  html, body { height: auto; min-height: 100%; }
  /* 16px avoids automatic input zoom on mobile Safari. */
  input:not([type="checkbox"]):not([type="radio"]), textarea, select {
    font-size: 16px !important;
    min-width: 0;
  }
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select {
    min-height: 44px;
  }
  button, .btn, .btn-outline, .resource-link, .knowledge-action-btn {
    min-height: 44px;
  }
  input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
  .page { padding: 20px 16px 40px; }
  .resources-page { margin: 24px auto; padding: 0; }
  .resources-title { font-size: 30px; }
  .resources-section h2 { font-size: 24px; }
  .resources-grid, .knowledge-grid, .knowledge-tabs { grid-template-columns: minmax(0, 1fr); }
  .resource-card, .knowledge-card { padding: 16px; }
  .resource-card h3, .knowledge-card h3 { font-size: 20px; }
  .action, .action .left, .action .left > div { min-width: 0; }
  .action .left { flex: 1; }
  .action .left > div { overflow-wrap: anywhere; }
  .action .left p { white-space: normal; }
  .form-actions, .actions { flex-wrap: wrap; }
  .guest-chat-page { margin: 24px auto !important; padding: 0 !important; }
  .guest-chat-page form { flex-wrap: wrap; }
  .guest-chat-page input[name="content"] { flex-basis: 100% !important; width: 100%; }
  .auth-container { padding: 16px; margin: auto; }
  .auth-card { padding: 24px 20px; }
  .chat-page .tool, .chat-page .suggested-panel-close,
  .mobile-sidebar-toggle { min-width: 44px; min-height: 44px; }
  .chat-page .composer { padding-bottom: max(18px, env(safe-area-inset-bottom)) !important; }
  .chat-page .composer-form { flex-wrap: wrap; }
  .chat-page .composer .box { flex-basis: calc(100% - 64px) !important; }
  .chat-page .autonomous-toggle {
    display: flex !important;
    order: 3;
    flex-basis: 100%;
    min-height: 32px;
    justify-content: flex-end;
  }
  .chat-page .suggested-panel-toggle { bottom: calc(var(--chat-composer-height, 190px) + 12px) !important; }
  .chat-page .thread { padding-bottom: calc(var(--chat-composer-height, 190px) + 64px) !important; }
  .chat-page .suggested-panel { padding-bottom: env(safe-area-inset-bottom); }
  .suggest-modal { z-index: 12000; padding: 12px; overflow-y: auto; }
  .suggest-modal-card { max-height: calc(100dvh - 24px); overflow-y: auto; padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
