/* Scoped to the Messages search form; keep dialogs and other forms unchanged. */
#search-form.search-card {padding:16px 28px}
#search-form .filter-heading {display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px 20px;margin:0 0 8px}
#search-form .participant-heading {display:flex;align-items:center;flex-wrap:wrap;gap:8px 18px;min-width:0}
#search-form .participant-heading>label,#search-form .field-label {margin:0;white-space:nowrap}
#search-form .check {display:inline-flex;align-items:center;gap:6px;margin:0;white-space:nowrap}
#search-form .check input[type=checkbox] {flex:0 0 auto;margin:0}
#search-form .source-controls,#search-form .source-options,#search-form #text-source-options {display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin:0}
#search-form .participants {margin:0 0 8px}
#search-form #selected:empty {display:none}
#search-form .combo {margin:0}
#search-form #participant,#search-form #phrase,#search-form input[type=date] {box-sizing:border-box;width:100%;min-width:0;height:44px;margin:0;padding:10px 14px}
#search-form .message-search-label-row {margin:0 0 4px;min-height:18px}
#search-form .bottom-filters {display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr) auto;align-items:center;gap:16px;margin-top:12px}
#search-form .bottom-filters>label {display:grid;grid-template-columns:56px minmax(0,1fr);align-items:center;gap:8px;width:auto;min-width:0;margin:0;white-space:nowrap}
#search-form .date-picker-wrap {width:100%;min-width:0}
#search-form .date-picker-wrap input {margin:0}
#search-form #submit {width:auto;height:44px;min-height:44px;padding:0 22px;margin:0}
#search-form .date-picker-wrap .date-calendar-open {width:32px;height:32px;min-width:0;min-height:0;margin:0;padding:6px}
@media(max-width:760px) {
 #search-form.search-card {padding:16px}
 #search-form .filter-heading {align-items:flex-start;gap:8px 16px}
 #search-form .participant-heading {gap:8px 14px}
 #search-form .source-controls {width:100%}
}
@media(max-width:600px) {
 #search-form .bottom-filters {grid-template-columns:minmax(0,1fr);gap:10px}
 #search-form #submit {width:100%}
}

/* Portal label badges use uppercase text consistently. */
.source{text-transform:uppercase}

/* Give native mobile date controls the full available row and allow intrinsic sizing to shrink. */
@media(max-width:600px){
 #search-form .bottom-filters{width:100%;max-width:100%;min-width:0}
 #search-form .bottom-filters>label{grid-template-columns:minmax(0,1fr);gap:4px;width:100%;max-width:100%;min-width:0;white-space:normal}
 #search-form .date-picker-wrap{display:block;box-sizing:border-box;width:100%;max-width:100%;min-width:0;min-inline-size:0}
 #search-form input[type=date]{display:block;box-sizing:border-box;width:100%;max-width:100%;min-width:0;min-inline-size:0}
 #search-form input[type=date]::-webkit-date-and-time-value{min-width:0;text-align:left}
}

/* Bound iOS native date sizing; reserve a separate calendar-button column. */
@media(max-width:600px){
 #search-form .date-picker-wrap{display:flex;align-items:center;box-sizing:border-box;inline-size:100%;max-inline-size:100%;min-inline-size:0;height:44px;border:1px solid #ccc;border-radius:6px;background:#fff;overflow:hidden}
 #search-form .date-picker-wrap input[type=date]{flex:1 1 0%;inline-size:0;width:0;min-inline-size:0;min-width:0;max-inline-size:100%;max-width:100%;height:42px;border:0;border-radius:0;box-shadow:none;-webkit-appearance:none;appearance:none;background:transparent;padding:10px 14px!important}
 #search-form .date-picker-wrap input[type=date]::-webkit-date-and-time-value{min-inline-size:0;text-align:left}
 #search-form .date-picker-wrap input[type=date]::-webkit-datetime-edit{min-inline-size:0;padding:0}
 #search-form .date-picker-wrap .date-calendar-open{position:static;transform:none;flex:0 0 32px;align-self:center;margin:0 4px 0 0}
 #search-form .date-picker-wrap:focus-within{outline:2px solid #164d45;outline-offset:2px}
 #search-form .date-picker-wrap input[type=date]:focus{outline:none}
}

/* Compact phone date range: paired fields, full-row Apply. */
@media(max-width:600px){
 #search-form .bottom-filters{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px 12px}
 #search-form .bottom-filters>label{width:100%;min-width:0}
 #search-form #submit{grid-column:1/-1;width:100%}
 #search-form .date-picker-wrap input[type=date]{padding-inline:8px!important;font-size:14px}
 #search-form .date-picker-wrap .date-calendar-open{flex-basis:28px;width:28px;margin-right:2px;padding:4px}
}

/* Match the conversation selection controls to the heading inset. */
#context #context-flag-toolbar{box-sizing:border-box;padding-inline:22px}

/* Size the message scroller after both header and selection controls. */
@media screen{
 #context[open]{display:flex;flex-direction:column;box-sizing:border-box;max-height:90vh;max-height:90dvh;overflow:hidden}
 #context>.dialog-heading,#context>#context-flag-toolbar{flex:0 0 auto}
 #context>#context-body{flex:1 1 auto;min-height:0;max-height:none;overflow-y:auto;overscroll-behavior:contain;padding-bottom:calc(12px + env(safe-area-inset-bottom,0px))}
}
