/* Smartphone-first finishing layer. Loaded last so every product surface shares
   the same touch, safe-area and narrow-viewport rules. */
html {
  max-width: 100%;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  scroll-padding-bottom: calc(92px + env(safe-area-inset-bottom));
}

body {
  min-width: 0;
  min-height: 100dvh;
  max-width: 100%;
  overflow-x: clip;
}

:where(img, svg, canvas, video, iframe) { max-width: 100%; }
:where(input, select, textarea, button) { max-width: 100%; }
:where(.field, .profile-field, .form-section, .review-card, .mission-card, .phase-card, .active-item, .room-card) { min-width: 0; }

.account-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  white-space: nowrap;
}

.account-shortcut-icon {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
}

.account-shortcut-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 780px) {
  :where(.field, .profile-field, .portal-field, .micro-label, .inline-field, .saved-property-picker, .catalog-filters, .composition-room-row label, .room-photo-fields label) {
    min-width: 0;
    max-width: 100%;
  }

  :where(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]), select, textarea) {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  select,
  textarea {
    min-height: 48px !important;
    font-size: 16px !important;
  }

  :where(.button, .text-button, .back-button, .portal-primary, .home-button, .account-trigger, .checklist-option, .choice-details > summary, .plain-help > summary, .review-disclosure > summary, .room-options > summary, .room-photo-import > summary) {
    min-height: 44px;
    touch-action: manipulation;
  }

  summary {
    min-height: 44px;
    display: flex;
    align-items: center;
    touch-action: manipulation;
  }

  .topbar {
    min-height: calc(68px + env(safe-area-inset-top));
    padding: calc(10px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
    position: sticky;
    top: 0;
    flex-wrap: nowrap;
    gap: 10px;
  }

  .topbar .brand { min-width: 0; }
  .topbar .brand-mark { width: 40px; height: 40px; flex: 0 0 40px; }
  .topbar .brand strong { white-space: nowrap; }
  .topbar .brand small { display: none; }
  .topbar .top-actions { width: auto; margin-left: auto; flex-wrap: nowrap; justify-content: flex-end; }
  .topbar .top-actions .button { min-height: 44px; padding-inline: 12px; font-size: 13px; }

  .sidebar,
  .inspection-sidebar {
    padding: 12px max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
  }

  .inspection-sidebar .dossier-card,
  .inspection-sidebar .privacy-note { display: none; }

  .inspection-nav-toggle {
    width: 100%;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: white;
    color: var(--primary-dark);
    font: inherit;
    font-size: 14px;
    font-weight: 800;
  }

  .inspection-nav-toggle > span:first-child { min-width: 0; display: grid; gap: 2px; text-align: left; }
  .inspection-nav-toggle strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .inspection-nav-toggle small { color: var(--muted); font-size: 11px; font-weight: 600; }

  .inspection-nav-toggle[aria-expanded="true"] > span:last-child { transform: rotate(180deg); }

  #step-nav,
  #inspection-nav {
    display: none;
    margin-top: 8px;
  }

  #step-nav.mobile-open,
  #inspection-nav.mobile-open {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 1px 1px 7px;
    overflow: visible;
  }

  #step-nav .nav-step,
  #inspection-nav .inspection-nav-button,
  #inspection-nav .inspection-nav-button.active {
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 48px;
    max-height: none;
    box-sizing: border-box;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 6px;
    text-align: center;
    scroll-snap-align: none;
  }

  .composition-summary { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .composition-flow > .composition-intro:not(.composition-heading) { display: none; }
  .composition-heading { margin-top: 18px; }
  .composition-heading > p { display: none; }
  .composition-editor { margin-top: 14px; }
  .composition-editor-content { padding-inline: 12px; }
  .final-review-summary { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .review-mode-tabs { grid-template-columns: 1fr; }
  .simple-comment-editor { grid-template-columns: 1fr; }
  .dictation-button { width: 100%; }
  .inspection-undo { bottom: var(--inspection-undo-bottom, calc(84px + env(safe-area-inset-bottom))); width: calc(100vw - 28px); justify-content: space-between; box-sizing: border-box; }

  #inspection-nav .inspection-nav-button span:first-child,
  #inspection-nav .inspection-nav-button.active span:first-child {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    margin: 0 auto;
    display: grid;
    place-items: center;
    line-height: 1;
  }

  #step-nav .nav-step span:last-child,
  #inspection-nav .inspection-nav-button span:last-child,
  #inspection-nav .inspection-nav-button.active span:last-child {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 30px;
    min-height: 30px;
    text-align: center;
    white-space: normal;
    font-size: 11px;
    line-height: 1.25;
  }

  .workspace,
  .inspection-workspace {
    padding-inline: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
  }

  #step-counter { display: none; }

  .workspace-header h1,
  .inspection-heading h1 { font-size: clamp(28px, 8.5vw, 36px); }
  .workspace-header p,
  .inspection-heading p,
  .form-section > p,
  .composition-intro > p,
  .room-photo-title p,
  .linked-defect-photo small { font-size: 14px; line-height: 1.55; }

  .field label,
  .profile-field label,
  .choice-field legend,
  .room-photo-fields label,
  .photo-category-field,
  .room-photo-warning,
  .room-photo-feedback,
  .photo-mobile-help { font-size: 14px; line-height: 1.45; }

  .field .hint,
  .choice-card small,
  .segment span,
  .checklist-option,
  .review-card p,
  .major-disclosure > summary small { font-size: 13px; line-height: 1.45; }

  .wizard-footer {
    position: sticky;
    bottom: 0;
    z-index: 18;
    display: grid;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.2fr);
    gap: 10px;
    margin-inline: calc(-1 * max(16px, env(safe-area-inset-left), env(safe-area-inset-right)));
    padding: 12px max(16px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    border-top: 1px solid rgba(158, 184, 172, .7);
    background: rgba(255, 255, 255, .97);
    box-shadow: 0 -10px 24px rgba(21, 63, 54, .08);
    backdrop-filter: blur(12px);
  }

  .wizard-footer .button { width: 100%; min-width: 0; min-height: 50px; padding-inline: 10px; font-size: 14px; }
  .wizard-footer > span { display: none; }

  dialog {
    width: calc(100% - 24px);
    max-width: calc(100% - 24px);
    max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    margin: auto;
  }
  .modal-card { max-height: inherit; padding: 24px 18px calc(20px + env(safe-area-inset-bottom)); }
  .modal-close { width: 44px; height: 44px; right: 10px; top: 10px; }
  .modal-card h2 { padding-right: 42px; font-size: 24px; }

  .counter-control button,
  .binary-control button,
  .access-counter-control button,
  .photo-category-choices button,
  .photo-note-choices button,
  .photo-link-current,
  .room-photo-actions .text-button,
  .photo-preview button { min-width: 44px; min-height: 44px; }

  .counter-control,
  .access-counter-control { grid-template-columns: 44px minmax(40px, 1fr) 44px; }
  .binary-control button { padding-block: 11px; }
  .bathroom-fixture .counter-control button { min-width: 44px; min-height: 44px; }
  .condition-choice span,
  .segment span { min-height: 44px; }
  .dossier-new-button { min-height: 44px; }
  .composition-room-actions button { min-height: 44px; }

  .composition-editor > header,
  .composition-add,
  .composition-add > * { min-width: 0; }
  .composition-add { width: 100%; }
  .composition-add select,
  .composition-add .button { width: 100%; }

  .room-photo-add { display: grid; grid-template-columns: 1fr; }
  .room-photo-add > :where(.button, .room-photo-import) { width: 100%; }
  .room-photo-import { min-width: 0; }
  .room-photo-import > summary { justify-content: center; padding: 10px 12px; font-size: 14px; }
  .room-photo-import > label { padding: 14px; font-size: 14px; }
  .photo-mobile-help { margin: 10px 0 0; color: var(--muted); }
  .room-photo-annotation > summary { min-height: 64px; }
  .room-photo-fields select,
  .room-photo-fields textarea { min-height: 48px; font-size: 16px; }
  .room-photo-actions { align-items: stretch; flex-direction: column; }
  .room-photo-actions > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .room-photo-actions > div > span { grid-column: 1 / -1; margin: 0; text-align: center; font-size: 12px; }
  .room-photo-actions .text-button { width: 100%; justify-content: center; font-size: 13px; }

  .visit-fast-bar {
    right: max(10px, env(safe-area-inset-right));
    bottom: calc(82px + env(safe-area-inset-bottom));
    left: max(10px, env(safe-area-inset-left));
  }

  .portal-header {
    padding: calc(12px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  }
  .portal-navigation a { min-height: 44px; display: inline-flex; align-items: center; }
  .quick-card { min-height: 104px; }

  .home-body a.home-button,
  .offer > a,
  .offer > summary { min-height: 44px; }
}

@media (max-width: 480px) {
  .topbar .top-actions :is(#home-button, a[href="/etat-des-lieux.html"], a[href^="/rediger-un-bail.html"]) { display: none; }
  :is(.lease-topbar, .parking-topbar) .top-actions > a[href="/dashboard.html"] { display: none; }
  :is(.lease-topbar, .parking-topbar) #reset-button { display: none; }
  .topbar .account-shortcut { display: inline-flex; }
  .topbar .top-actions .button { white-space: normal; }
  .workspace,
  .inspection-workspace { padding-top: 22px; }
  .form-section,
  .mission-card,
  .major-disclosure-content { padding-inline: 15px; }
  .composition-question { padding: 14px 12px; }
  .access-photo-card { grid-template-columns: 64px minmax(0, 1fr); }
  .access-photo-card > :where(.text-button, button.text-button) { width: 100%; }
  .inspection-workspace { padding-bottom: 112px; }
  .choice-surface .segment span {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: center;
    justify-content: stretch;
    column-gap: 12px;
    padding-inline: clamp(20px, 7vw, 32px);
    text-align: left;
  }
}

@media (max-width: 360px) {
  .topbar .brand { min-width: 44px; justify-content: center; }
  .topbar .brand > span:last-child { display: none; }
  .portal-header .brand { width: 44px; min-width: 44px; }
  .portal-header .brand > :is(span, strong):not(.brand-mark) { display: none; }
  .portal-header .brand-mark { width: 44px; height: 44px; flex: 0 0 44px; }
  #step-nav .nav-step,
  #inspection-nav .inspection-nav-button,
  #inspection-nav .inspection-nav-button.active { flex-basis: 102px; width: 102px; min-width: 102px; }
  .wizard-footer { grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr); }
  .wizard-footer .button { font-size: 13px; }
}

@media (max-height: 520px) and (max-width: 900px) {
  .topbar { position: relative; }
  .wizard-footer { position: static; }
  .visit-fast-bar { position: static; margin: 14px 0; }
  summary,
  .button,
  .text-button,
  .back-button,
  .home-button,
  .offer > a { min-height: 44px; }
  .bathroom-fixture .counter-control button,
  .counter-control button,
  .access-counter-control button { min-width: 44px; min-height: 44px; }
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  select,
  textarea { min-height: 48px !important; font-size: 16px !important; }
  .condition-choice span,
  .segment span,
  .composition-room-actions button { min-height: 44px; }
  .composition-editor > header { display: grid; align-items: stretch; }
  .composition-add { grid-template-columns: 1fr auto; }
  .composition-room-row { grid-template-columns: 28px 1fr 1fr; }
  .composition-room-name,
  .composition-room-options { grid-column: 2 / -1; }
  .composition-room-empty { display: none; }
  .room-navigator { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .condition-choice > div { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

@supports not (overflow: clip) {
  html, body { overflow-x: hidden; }
}
