/* The Bit Library — cross-page readability and usability refinements v11.2.0
   Presentation/accessibility layer only: no route, form name, permission, query, or business-rule changes. */
@media screen {
  :root {
    --bit-usable-control-height: 42px;
    --bit-usable-radius: 10px;
    --bit-usable-focus: 0 0 0 3px color-mix(in srgb, var(--primary, #2563eb) 22%, transparent);
  }

  html { scroll-padding-top: 92px; }
  body.app-body, body.opac-body, body.login-body, body.register-body {
    font-family: Prompt, Tahoma, Arial, sans-serif;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
  }
  body.app-body { line-height: 1.65; }
  body.app-body .main-wrapper,
  body.app-body .content-area,
  body.app-body :is(.page-heading, .toolbar, .toolbar-left, .toolbar-right,
    .form-grid, .form-grid-2, .form-grid-3, .form-row, .stat-grid, .collection-grid) {
    min-width: 0;
    max-width: 100%;
  }
  body.app-body .content-area { padding-inline: clamp(0px, .5vw, 8px); }
  body.app-body .page-heading { gap: 12px; align-items: flex-start; }
  body.app-body .page-heading h1 { line-height: 1.4; overflow-wrap: anywhere; }
  body.app-body .page-heading p { max-width: 78ch; line-height: 1.75; }
  body.app-body :is(.section-note, .settings-note, .upload-help, .field-help,
    .help-text, .muted, .small) { overflow-wrap: anywhere; }
  body.app-body .bento-box,
  body.app-body :is(.panel, .card, .box, .form-card, .settings-card,
    .report-card, .table-card, .member-card, .item-card, .collection-card) {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  /* Consistent touch targets and readable form controls across older and newer pages. */
  body.app-body :is(input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]),
    select, textarea, .input, .textarea, .form-control, .form-select,
    .form-textarea, .search-control, .search-input) {
    max-width: 100%;
    min-height: var(--bit-usable-control-height);
    border-radius: var(--bit-usable-radius);
    line-height: 1.45;
  }
  body.app-body textarea,
  body.app-body :is(.textarea, .form-textarea) { min-height: 104px; }
  body.app-body :is(label, .form-label, .setting-label) { line-height: 1.6; }
  body.app-body :is(.field, .form-group, .form-col, .setting-field, .manual-field) { min-width: 0; }
  body.app-body :is(.btn-primary, .btn-secondary, .btn-danger, .btn-success,
    .btn-save, .btn-cancel, .btn-back, .btn-add, .btn-submit, .btn-ghost,
    .btn-light, .btn-delete, .btn-remove, .btn-ready, .btn-pay, .btn-action,
    .btn-register, .btn-borrow, .btn-approve, .btn-done, .btn, .q-btn,
    button[type="submit"], input[type="submit"]) {
    min-height: 40px;
    max-width: 100%;
    line-height: 1.45;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  body.app-body :is(.toolbar, .toolbar-left, .toolbar-right, .form-actions,
    .settings-actions, .report-actions, .btnbar, .actions) { min-width: 0; }
  body.app-body :is(.actions, .action-buttons, .table-actions) {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
  }
  body.app-body :is(button, a, input, select, textarea, summary):focus-visible {
    outline: 3px solid color-mix(in srgb, var(--primary, #2563eb) 65%, transparent);
    outline-offset: 2px;
  }
  body.app-body :is(button:disabled, input:disabled, select:disabled, textarea:disabled) {
    cursor: not-allowed;
  }

  /* Readable tables: keep wide data scrollable instead of cropping text/actions. */
  body.app-body :is(.table-wrap, .table-responsive, .table-container,
    .table-scroll-x, .report-table-wrap, .mobile-table-scroll) {
    max-width: 100%;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  body.app-body :is(.table-wrap, .table-responsive, .table-container,
    .table-scroll-x, .report-table-wrap) > table:not(.responsive-stack-table) {
    max-width: 100%;
  }
  body.app-body :is(table.data-table, table.report-table, .table-wrap table,
    .table-responsive table, .table-container table) th {
    line-height: 1.55;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  body.app-body :is(table.data-table, table.report-table, .table-wrap table,
    .table-responsive table, .table-container table) td {
    line-height: 1.6;
    vertical-align: top;
    overflow-wrap: anywhere;
  }
  body.app-body :is(table.data-table, table.report-table) :is(button, .btn-primary, .btn-secondary, .btn-danger) {
    margin: 1px 2px 1px 0;
  }
  body.app-body :is(.empty, .empty-state, .no-data) {
    padding: clamp(20px, 4vw, 36px) 16px;
    text-align: center;
    line-height: 1.8;
  }

  /* Feedback and confirmation text should be scannable and not rely on color alone. */
  body.app-body :is(.flash, .alert, .alert-success, .alert-error, .alert-info, .alert-warning) {
    line-height: 1.75;
    overflow-wrap: anywhere;
  }
  body.app-body :is(.status-badge, .status-pill, .badge, .pill) {
    max-width: 100%;
    line-height: 1.5;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  body.app-body :is(.modal-content, dialog, .confirm-dialog) { max-width: min(96vw, 720px); }
  body.app-body a[id], body.app-body [id^="group-"] { scroll-margin-top: 96px; }
  img, svg, video, canvas { max-width: 100%; }

  /* Public catalogue pages use the same reading rhythm and clearer input sizes. */
  body.opac-body { line-height: 1.7; }
  body.opac-body :is(.search-panel, .opac-panel, .manual-shelf, .card) { min-width: 0; }
  body.opac-body :is(input, select, button, .opac-detail-link) { min-height: 42px; }
  body.opac-body :is(.hero h1, .page-title) { line-height: 1.4; overflow-wrap: anywhere; }

  /* Respect the saved dark palette for older page-specific components. */
  html[data-theme="dark"] body.app-body :is(.table-wrap, .table-responsive,
    .table-container, .table-scroll-x, .report-table-wrap) { border-color: var(--border, #334155); }
  html[data-theme="dark"] body.app-body :is(.table-wrap, .table-responsive,
    .table-container, .table-scroll-x, .report-table-wrap) table { color: var(--text, #e5e7eb); }
  html[data-theme="dark"] body.app-body :is(.table-wrap, .table-responsive,
    .table-container, .table-scroll-x, .report-table-wrap) tbody td { border-color: var(--border, #334155); }
  html[data-theme="dark"] body.app-body :is(.field-help, .help-text, .upload-help, .section-note) {
    color: var(--muted, #a8b4c5);
  }

  @media (max-width: 820px) {
    body.app-body { gap: 10px; }
    body.app-body .content-area { padding: 2px 0 24px; }
    body.app-body .page-heading { flex-direction: column; align-items: stretch; }
    body.app-body .page-heading > :last-child { max-width: 100%; }
    body.app-body :is(.toolbar, .toolbar-left, .toolbar-right, .form-actions,
      .settings-actions, .report-actions, .btnbar) { flex-wrap: wrap; }
    body.app-body :is(.toolbar-left, .toolbar-right) > * { max-width: 100%; }
    body.app-body :is(.stat-grid, .form-grid, .form-grid-2, .form-grid-3) > * { min-width: 0; }
  }
  @media (max-width: 520px) {
    body.app-body :is(input:not([type="hidden"]), select, textarea,
      .form-control, .form-select, .form-textarea, .search-control) { font-size: 16px; }
    body.app-body :is(.btn-primary, .btn-secondary, .btn-danger, .btn-success,
      .btn-save, .btn-cancel, .btn-back, .btn-add, .btn-submit, .btn-ghost,
      .btn-light, .btn-delete, .btn-remove, .btn-ready, .btn-pay, .btn-action,
      .btn-register, .btn-borrow, .btn-approve, .btn-done, .btn, .q-btn) { min-height: 44px; }
    body.app-body .bento-box { padding: 14px; }
    body.app-body :is(.toolbar-left, .toolbar-right) { width: 100%; }
    body.app-body :is(.toolbar-left, .toolbar-right) > a,
    body.app-body :is(.toolbar-left, .toolbar-right) > button { max-width: 100%; }
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
  }
}
