/* Shared responsive finish. The drawer breakpoint remains 800px, matching app.js. */
.explore-layout > *, .profile-editor-layout > *, .profile-editor-form,
.profile-editor-form .form-grid > *, .profile-fields > *,
.dossier-grid > *, .source-row > div, .amount-input, .amount-input input {
  min-width: 0;
}
.profile-editor-form fieldset { min-inline-size: 0; }
.quote-table-wrap { overscroll-behavior-inline: contain; }
.source-row > div, .deadline-item > div, .selection-row > div {
  overflow-wrap: anywhere;
}
.profile-save-bar > *, .profile-save-bar .button-row { min-width: 0; }
.profile-save-bar .button-row { justify-content: flex-end; }
.profile-save-bar .button { flex-shrink: 0; }

/* A second navigation row gives all seven destinations their own room. */
@media screen and (min-width: 801px) and (max-width: 1360px) {
  .sidebar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px 24px;
    padding-block: 12px;
  }
  .sidebar > .brand { grid-column: 1; grid-row: 1; }
  .sidebar > .header-tools {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    gap: 10px;
  }
  .sidebar .primary-navigation {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: center;
    gap: 4px;
  }
  .sidebar .nav-item { min-height: 44px; padding: 10px 13px; font-size: 12px; }
  .project-aside, .profile-perspective, .budget-summary { top: 150px; }
  #page-profil [id], .category-context { scroll-margin-top: 155px; }
  .language-picker select { min-width: 102px; font-size: 12px; }
}

/* Forms keep two useful columns instead of competing with a narrow sidebar. */
@media screen and (max-width: 1100px) {
  .workspace-strip { flex-wrap: wrap; row-gap: 12px; }
  .workspace-strip > div:first-child { flex: 1 1 380px; }
  .workspace-strip .workspace-tools { margin-inline-start: auto; }
  .workspace-strip select { min-width: 0; }
  .profile-editor-layout { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .profile-perspective { position: static; }
  .budget-layout { grid-template-columns: minmax(0, 1fr); }
  .budget-summary { position: static; }
  .profile-save-bar { flex-wrap: wrap; }
  .profile-save-bar .button-row { margin-inline-start: auto; }
}

@media screen and (min-width: 621px) and (max-width: 1100px) {
  .profile-editor-form .form-grid { gap: 22px 26px; }
  .profile-perspective { padding: 28px; border-radius: 16px 16px 45px 16px; }
  #profile-budget-picture { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 24px; }
  #profile-budget-picture > .hint,
  #profile-budget-picture > .allocation-note { grid-column: 1 / -1; }
  .profile-allocation { justify-content: space-between; }
  .profile-allocation strong { font-size: 19px; line-height: 1.4; }
  .profile-allocation.allocation-total strong { font-size: 23px; }
}

@media screen and (min-width: 801px) and (max-width: 960px) {
  .sidebar .nav-item { padding-inline: 11px; }
}

@media screen and (max-width: 1230px) {
  html[dir="rtl"] .cards.list-view .offer-actions {
    border-inline-start: 0;
    padding-inline-start: 0;
  }
  html[dir="rtl"] .cards.list-view .offer-actions .text-button {
    margin-right: 0;
    margin-inline-end: auto;
  }
}

/* Comfortable controls also work with a finger and a software keyboard. */
@media screen and (max-width: 800px) {
  .topbar #mobile-menu, .topbar #launch-wizard, .drawer-close,
  .sidebar #motion-toggle {
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
  }
  .topbar .mobile-language select { min-height: 44px; }
  html .topbar .mobile-language select:not([multiple]):not([size]),
  html[dir="rtl"] .topbar .mobile-language select:not([multiple]):not([size]) {
    padding-inline: 10px 30px;
  }
  .sidebar .header-tools { padding-bottom: env(safe-area-inset-bottom, 0px); }
  .sidebar .header-tools .language-picker select { min-height: 44px; }
  .workspace-strip .text-button, .workspace-strip .button,
  .compare-tray > .text-button, .compare-tray > .button,
  .profile-save-bar .text-button, .profile-save-bar .button,
  .offer-actions .text-button, .offer-actions .compare-button,
  .dossier-controls .text-button, .source-row > a {
    min-height: 44px;
  }
  .view-switch button, .favorite-button, .tray-chip button,
  .selection-row .icon-button, .deadline-item .icon-button,
  #close-modal {
    min-width: 44px;
    min-height: 44px;
  }
  .tray-chip { padding-inline-end: 0; }
  .tray-chip button { border-radius: 50%; }
  .view-switch { padding: 2px; }
  .favorite-button { top: 10px; }
  .offer-header, .cards.list-view .offer-header { padding-inline-end: 34px; }
  .cards.list-view .favorite-button { top: 12px; }
  html[dir="rtl"] .offer-header,
  html[dir="rtl"] .cards.list-view .offer-header { padding-left: 34px; padding-right: 0; }
  .profile-save-bar .button-row { flex-wrap: wrap; }
  dialog { max-height: calc(100dvh - 24px); }
}

/* 16px form text prevents the browser from zooming the page on field focus. */
@media screen and (max-width: 800px), screen and (pointer: coarse) and (max-width: 1100px) {
  .profile-editor-form :is(input, select),
  .profile-fields select, .workspace-strip select, .result-controls select,
  .budget-layout .form-label select, .amount-input input,
  .modal-form :is(input, select, textarea), .modalForm :is(input, select, textarea),
  .quote-filter-bar select, #search-offers, #project-notes,
  .guide-form-grid :is(input,select), .guide-tools :is(input,select),
  .topbar .mobile-language select, .sidebar .language-picker select {
    font-size: 16px;
  }
  .topbar .mobile-language select { min-width: 104px; max-width: 108px; }
  .sidebar .language-picker select { min-width: 124px; }
}

@media screen and (max-width: 620px) {
  .workspace-strip > div:first-child { flex-basis: 100%; }
  .workspace-strip select { min-height: 44px; }
  .workspace-tools .sync-badge { flex: 1; min-width: 0; }
  .workspace-tools > .button { flex-shrink: 0; }
  .result-controls { gap: 10px; }
  .directory-toolbar { gap: 10px; }
  html[dir="rtl"] .directory-toolbar > .view-switch { margin-left: 0; margin-inline-start: auto; }
  .directory-toolbar .filter-chip { min-height: 48px; }
  .profile-save-bar .button-row { width: 100%; margin-inline: 0; }
  .profile-save-bar .button { white-space: normal; text-align: center; }
  .compare-tray { inset-inline: 10px; }
  .compare-tray #tray-chips { padding-block: 2px; }
  .compare-tray .tray-chip { max-width: min(240px, 80vw); }
  .source-row > a { display: inline-flex; align-items: center; }
}

@media screen and (max-width: 420px) {
  /* Keep the logo, language name and project action fully visible together. */
  .topbar .wizard-link-short { display: none; }
  .topbar #launch-wizard { justify-content: center; }
  .topbar-actions { gap: 5px; }
  .topbar-left { gap: 6px; }
  .profile-save-bar .button-row { flex-direction: column; align-items: stretch; }
  .profile-save-bar .button-row > * { justify-content: center; }
}

@media screen and (max-width: 360px) {
  .result-controls { grid-template-columns: minmax(0, 1fr); }
  #sort { grid-column: auto; }
  .topbar { gap: 4px; }
  .topbar .mobile-language select { min-width: 104px; max-width: 104px; }
  .compare-tray { column-gap: 8px; padding-inline: 10px; }
}

/* Short landscape screens need the editing area more than a floating footer. */
@media screen and (max-height: 540px) {
  .profile-editor-form[data-docked="true"] .profile-save-bar { position: static; }
  .project-aside, .profile-perspective, .budget-summary { position: static; }
  .compare-tray { padding-block: 8px; row-gap: 3px; }
  .compare-tray > div:first-child span { display: none; }
}
@media screen and (min-width: 801px) and (max-height: 600px) {
  .sidebar { position: relative; }
  #page-profil [id], .category-context { scroll-margin-top: 20px; }
}

/* Activity detail stays with its selector, including narrow and RTL layouts. */
.activity-criteria {display:grid;align-content:start;gap:14px;min-width:0;}
.activity-criteria input {width:100%;min-width:0;min-height:46px;}
.quick-criteria{grid-column:1/-1;min-width:0;border-top:1px solid #e3eae5;padding-top:14px;}
.quick-criteria summary{display:flex;justify-content:space-between;align-items:center;gap:12px;cursor:pointer;font-size:13px;font-weight:750;color:#183b3d;list-style:none;}
.quick-criteria summary::-webkit-details-marker{display:none;}
.quick-criteria summary::after{content:'+';font-size:19px;line-height:1;color:#345d56;}
.quick-criteria[open] summary::after{content:'−';}
.quick-criteria-hint{margin-inline-start:auto;font-size:11px;font-weight:500;color:#627874;}
.quick-criteria-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-top:18px;}
.quick-criteria-grid label{min-width:0;}
.quick-criteria-grid input,.quick-criteria-grid select{width:100%;min-height:44px;}
.quick-criteria-note{margin:14px 0 0;color:#657a76;font-size:12px;line-height:1.5;}
.match-reason{display:flex;align-items:flex-start;gap:7px;margin:7px 0 0;color:#315d52;font-size:12px;line-height:1.45;}
.match-reason .icon{width:14px;height:14px;flex:none;margin-top:1px;}
@media(max-width:600px){.quick-criteria-grid{grid-template-columns:1fr}.quick-criteria-hint{display:none}}
#profile-activity-detail-field>span {line-height:1.5;}
@media(max-width:800px){.activity-criteria input {font-size:16px;min-height:48px;}}
