/* New controls have no desktop presentation; approved desktop rules remain intact. */
.catalog-phone-filter { display: none; }

@media (max-width: 767px), (max-width: 959px) and (max-height: 500px) and (pointer: coarse) and (orientation: landscape) {
  .catalog-shell .catalog-page-content { padding: 6px 8px max(8px, env(safe-area-inset-bottom)); }
  .topbar.catalog-topbar { display: grid; grid-template-columns: 40px minmax(0,1fr); gap: 3px 6px; min-height: 0; padding: 5px 8px; }
  .catalog-topbar > .mobile-menu-toggle { grid-column: 1; grid-row: 1; width: 40px; height: 40px; min-height: 40px; padding: 8px; }
  .catalog-topbar > .topbar-heading { grid-column: 2; grid-row: 1; min-width: 0; }
  .catalog-topbar h1 { margin: 0; font-size: 18px; line-height: 1.2; }
  .catalog-topbar > .topbar-tools-host:empty { display: none; }
  .catalog-top-navigation { grid-column: 1 / -1; grid-row: 2; flex-basis: auto; width: 100%; margin: 0; justify-content: space-between; gap: 3px; }
  .catalog-top-link { flex: 1 1 0; width: auto; min-width: 0; height: 40px; min-height: 40px; padding: 6px; }
  .catalog-top-link-label { display: none; }
  .catalog-top-link svg { width: 18px; height: 18px; }
  .catalog-module { gap: 6px; }
  .catalog-module-panel, .message-templates-view { gap: 6px; padding: 8px; border-radius: var(--radius-md); }
  .catalog-module-heading, .message-template-heading { display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 4px 6px; align-items: center; }
  .catalog-module-heading h2, .message-template-heading h2 { min-width: 0; font-size: 16px; line-height: 1.2; overflow-wrap: anywhere; }
  .catalog-result-count { font-size: 12px; white-space: nowrap; }
  .catalog-module-heading > .catalog-command { width: 40px; height: 40px; min-height: 40px; padding: 7px; }
  .catalog-module-heading > .catalog-command .record-action-label,
  .message-template-heading > .primary-button .record-action-label { display: none; }
  .catalog-module-heading:has(> :nth-child(4)) { grid-template-columns: minmax(0,1fr) auto 40px 40px; }
  .catalog-module-heading.catalog-entity-heading { grid-template-columns: max-content minmax(max-content,1fr) 40px 40px; }
  .catalog-module-heading.catalog-entity-heading > h2 { white-space: nowrap; overflow-wrap: normal; }
  .catalog-module-heading.catalog-entity-heading > .catalog-result-count { justify-self: start; }
  .catalog-module-heading.catalog-entity-heading .catalog-result-count-unit,
  .catalog-module-heading.catalog-entity-heading > .entity-category-manage > span { display: none; }
  .catalog-module-heading.catalog-entity-heading > :is(.catalog-command,.entity-category-manage) { box-sizing: border-box; width: 40px; min-width: 40px; max-width: 40px; height: 40px; min-height: 40px; padding: 7px; }
  .message-template-heading-copy { gap: 3px; }
  .message-template-heading > .primary-button { width: 40px; height: 40px; min-height: 40px; padding: 7px; }
  .catalog-module-filters { display: grid; grid-template-columns: minmax(0,1fr) 40px; gap: 6px; }
  .catalog-module-filters > input { min-width: 0; width: 100%; }
  .catalog-module-filters > .catalog-state-select, .catalog-module-filters > .catalog-scope-filter-trigger { display: none; }
  .catalog-module-panel > .catalog-scope-filters { display: none; }
  .catalog-phone-filter { display: inline-flex; width: 40px; height: 40px; min-height: 40px; padding: 7px; }
  .catalog-module :is(input:not([type=checkbox]):not([type=radio]),select,textarea),
  .message-templates-view :is(input:not([type=checkbox]):not([type=radio]),select,textarea) { box-sizing: border-box; min-height: 40px; padding: 7px 8px; font-size: 16px; line-height: 1.25; }
  .catalog-mobile-navigation { display: flex; flex-wrap: nowrap; gap: 3px; padding: 3px; border: 1px solid var(--border-default); border-radius: 8px; background: var(--surface); }
  .catalog-mobile-navigation > .catalog-command { flex: 1 1 0; min-width: 0; min-height: 40px; padding: 6px; border-color: transparent; font-size: 13px; line-height: 1.2; }
  .catalog-mobile-navigation svg { display: none; }
  .catalog-module-records { gap: 6px; padding: 1px; scrollbar-gutter: auto; }
  .catalog-module-row { display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 5px; padding: 8px; }
  .catalog-module-row > :first-child { flex-basis: auto; grid-column: 1; min-width: 0; }
  .catalog-module-row .catalog-module-identity, .catalog-module-row .catalog-select-record { gap: 2px; }
  .catalog-module-row strong { font-size: 14px; line-height: 1.25; }
  .catalog-module-row .catalog-module-identity > span, .catalog-module-row .catalog-select-record > span { font-size: 12px; line-height: 1.3; }
  .catalog-module-row > .badge { grid-column: 2; padding: 3px 5px; font-size: 11px; line-height: 1.2; white-space: nowrap; }
  .catalog-module-row-actions { grid-column: 3; display: flex; flex-wrap: nowrap; gap: 3px; margin: 0; }
  .catalog-module-row-actions > .catalog-command { width: 40px; height: 40px; min-height: 40px; padding: 7px; }
  .catalog-module-row-actions svg { width: 17px; height: 17px; }
  .message-template-record { padding: 8px; }
  .message-template-record-line { gap: 6px; }
  .message-template-record-copy > strong { font-size: 14px; line-height: 1.25; }
  .message-template-record-meta { font-size: 12px; line-height: 1.3; }
  .message-template-record-actions { gap: 3px; }
  .message-template-record-actions > .catalog-command { flex-basis: 40px; width: 40px; height: 40px; min-height: 40px; padding: 7px; }
  .message-template-visibility-mark { padding: 2px 0; }
  .message-template-visibility-mark > span { display: none; }
  .message-template-filters { gap: 5px; }
  .message-template-filters > .catalog-command { width: 40px; height: 40px; min-height: 40px; padding: 7px; }
  .message-templates-view .message-template-info { width: 30px; flex-basis: 30px; min-height: 36px; padding: 5px; }
  .message-template-form.catalog-editor-form { gap: 6px; }
  .message-template-form > h3 { font-size: 16px; }
  .message-template-form > .message-template-layout { gap: 6px; }
  .message-template-identification { grid-template-columns: minmax(0,1fr); gap: 6px; }
  .message-template-identification > label { gap: 3px; font-size: 13px; }
  .message-template-form textarea { min-height: 40px; height: 40px; max-height: 64px; }
  .message-template-mobile-regions { gap: 4px; }
  .message-template-mobile-regions > button { min-height: 40px; padding: 6px; font-size: 13px; }
  .message-template-configuration { gap: 6px; padding: 1px; scrollbar-gutter: auto; }
  .message-template-field-group { gap: 5px; padding-top: 6px; }
  .message-template-context-group { gap: 3px; padding: 0; }
  .message-template-group-title, .message-template-check { font-size: 13px; line-height: 1.3; }
  .message-template-check { align-items: center; gap: 5px; min-height: 32px; }
  .message-template-availability-options { gap: 4px 8px; }
  .message-template-form .message-template-associations { padding-top: 6px; gap: 5px; }
  .message-template-footer { gap: 4px; padding-top: 6px; }
  .message-template-footer .entity-form-actions > .catalog-command { min-height: 40px; padding: 6px 10px; font-size: 13px; }
  .message-template-content-heading h3 { font-size: 14px; }
  .message-template-form .catalog-selection-modes { display: none; }
  .message-template-form .catalog-scope-title-line { min-height: 32px; }
  .catalog-phone-filters { position: fixed; z-index: 50; inset: auto; margin: 0; box-sizing: border-box; width: min(340px, calc(100vw - 16px)); padding: 10px; border: 1px solid var(--border-default); border-radius: 8px; background: var(--surface); color: var(--text-primary); box-shadow: var(--shadow-sm); overflow-y: auto; }
  .catalog-phone-filters-header { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
  .catalog-phone-filters-title { margin: 0; font-size: 16px; }
  .catalog-phone-filters-close { width: 40px; height: 40px; min-height: 40px; padding: 6px; }
  .catalog-phone-filters-body { display: grid; gap: 8px; }
  .catalog-phone-filters :is(select,input:not([type=checkbox])) { box-sizing: border-box; width: 100%; min-width: 0; min-height: 40px; font-size: 16px; }
  .catalog-phone-filters .catalog-scope-filters { max-height: none; overflow: visible; }
  .catalog-phone-filters-actions { display: flex; justify-content: flex-end; margin-top: 8px; }

  .mobile-catalog-surface { position: fixed; z-index: 40; box-sizing: border-box; display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100dvh; padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-left)); background: var(--surface); color: var(--text-primary); }
  .mobile-catalog-header { display: flex; flex: 0 0 auto; align-items: center; gap: 6px; min-width: 0; padding: 5px 0; border-bottom: 1px solid var(--border-subtle); }
  .mobile-catalog-header h2 { flex: 1; min-width: 0; margin: 0; font-size: 17px; line-height: 1.25; overflow-wrap: anywhere; }
  .mobile-catalog-back { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 40px; width: 40px; height: 40px; min-height: 40px; padding: 8px; }
  .mobile-catalog-back svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .mobile-catalog-body { display: flex; flex-direction: column; flex: 1 1 0; min-width: 0; min-height: 0; padding-top: 6px; overflow-y: auto; scroll-padding-block: 8px; }
  .mobile-catalog-body > .catalog-module-editor { flex: 0 0 auto; min-height: 0; max-block-size: none; width: 100%; box-sizing: border-box; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; }
  .mobile-catalog-body > .catalog-module-editor > h3 { display: none; }
  .mobile-catalog-body .catalog-module-editor > form.catalog-editor-form { flex: 0 0 auto; min-height: 0; gap: 6px; }
  .mobile-catalog-body .catalog-module-editor .catalog-form-fields { display: grid; flex: 0 0 auto; grid-template-columns: minmax(0,1fr); gap: 8px; min-height: 0; max-height: none; overflow: visible; padding: 2px; }
  .mobile-catalog-body .catalog-form-fields > *, .mobile-catalog-body .catalog-ticket-field-row > *, .mobile-catalog-body .catalog-company-identification > *, .mobile-catalog-body .catalog-department-identification > * { grid-column: 1 / -1; grid-row: auto; }
  .mobile-catalog-body :is(.catalog-ticket-field-row,.catalog-association-controls,.catalog-association-pair,.catalog-company-identification,.catalog-department-identification,.catalog-form-region) { display: grid; grid-template-columns: minmax(0,1fr); gap: 6px; min-width: 0; }
  .mobile-catalog-body :is(input:not([type=checkbox]):not([type=radio]):not([type=hidden]),select,textarea) { box-sizing: border-box; width: 100%; min-width: 0; min-height: 40px; padding: 7px 8px; font-size: 16px; line-height: 1.25; }
  .mobile-catalog-body :is(label,legend) { font-size: 13px; line-height: 1.3; }
  .mobile-catalog-body :is(h4,h5) { margin: 0; font-size: 14px; line-height: 1.3; }
  .mobile-catalog-body .catalog-remote-scope { min-width: 0; gap: 5px; padding: 7px; }
  .mobile-catalog-body .catalog-editor-form .catalog-selection-modes { display: none; }
  .mobile-catalog-body .catalog-selection-chips { min-height: 0; gap: 4px; }
  .mobile-catalog-body .catalog-scope-header { align-items: center; gap: 4px; }
  .mobile-catalog-body .catalog-scope-title-line { min-height: 32px; }
  .mobile-catalog-body .catalog-scope-toggle { min-height: 40px; }
  .mobile-catalog-body .catalog-module-editor .entity-form-actions { flex: 0 0 auto; flex-wrap: nowrap; gap: 6px; padding: 6px 0; }
  .mobile-catalog-body .entity-form-actions > button { min-height: 40px; padding: 6px 10px; font-size: 14px; }
  .mobile-catalog-body .catalog-editor-form > .form-error { max-height: 60px; overflow-y: auto; font-size: 12px; }
  .mobile-catalog-selection { display: flex; flex-direction: column; flex: 1 1 0; gap: 6px; min-width: 0; min-height: 0; }
  .mobile-catalog-selection-controls { display: flex; flex-direction: column; flex: 0 0 auto; gap: 6px; min-width: 0; max-height: 40%; overflow-y: auto; }
  .mobile-catalog-selection .catalog-selection-modes { display: flex; flex-wrap: wrap; gap: 4px 10px; min-height: 0; }
  .mobile-catalog-selection :is(.catalog-scope-mode,.catalog-scope-option) { display: flex; align-items: center; gap: 6px; min-height: 40px; min-width: 0; font-size: 14px; }
  .mobile-catalog-selection .catalog-scope-option { padding: 6px; }
  .mobile-catalog-selection input[type=checkbox] { flex: 0 0 18px; width: 18px; height: 18px; min-height: 18px; margin: 0; accent-color: var(--brand); }
  .mobile-catalog-selection > .catalog-choice-page { display: flex; flex-direction: column; flex: 1 1 0; min-height: 0; max-block-size: none; overflow-y: auto; padding: 2px; }
  .mobile-catalog-selection-footer { display: flex; flex: 0 0 auto; justify-content: flex-end; padding-block: 6px; border-top: 1px solid var(--border-subtle); }
  .mobile-catalog-selection-footer > button { min-height: 40px; padding: 6px 12px; font-size: 14px; }
  .mobile-catalog-surface [hidden] { display: none; }
  .mobile-catalog-surface :is(button,input,select,textarea):focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

  @media (min-width: 390px) {
    .topbar.catalog-topbar { grid-template-columns: 40px minmax(0,1fr) auto; }
    .catalog-top-navigation { grid-column: 3; grid-row: 1; width: auto; }
    .catalog-top-link { flex: 0 0 36px; width: 36px; }
  }
  @media (max-width: 359px) {
    .catalog-module-row { grid-template-columns: minmax(0,1fr) auto; }
    .catalog-module-row > :first-child { grid-row: 1 / 3; }
    .catalog-module-row > .badge { grid-column: 2; grid-row: 1; justify-self: end; }
    .catalog-module-row-actions { grid-column: 2; grid-row: 2; }
    .message-template-record-line { grid-template-columns: minmax(0,1fr); gap: 5px; }
    .message-template-record-actions { justify-content: flex-end; }
  }
}
