/* Small-screen space belongs to the profile and saved work, not nested gutters. */
@media (max-width: 1100px) {
  :is(#baseMembers, #baseAccounts) :is(.talent-resume, .resume-reading-content, .local-profile-editor, .editor-main, .editor-card, .audition-history-workspace, .local-audition-review, .message-workspace, .message-list, .message-detail) {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }
  :is(#baseMembers, #baseAccounts) :is(#ViewProfileMembers, #UpdateProfileMembers, #ViewProfile, .audition-history-workspace) > .container {
    width: 100%; max-width: 100%; padding-inline: 0 !important;
  }
  :is(#baseMembers, #baseAccounts) :is(#ViewProfileMembers, #UpdateProfileMembers, #ViewProfile, .audition-history-workspace) > .container > .row {
    margin-inline: 0;
  }
  :is(#baseMembers, #baseAccounts) :is(#ViewProfileMembers, #UpdateProfileMembers, #ViewProfile, .audition-history-workspace) > .container > .row > [class*="col-"] {
    padding-inline: 0; min-width: 0;
  }
  :is(#baseMembers, #baseAccounts) .talent-resume.profile-reading-sheet {
    width: 100% !important; max-width: 100% !important; padding: 18px 10px; margin: 0 !important;
    border: 0 !important; border-radius: 0 !important; box-shadow: none !important;
  }
  :is(#baseMembers, #baseAccounts) .resume-reading-content { max-width: 100%; }
  /* Preserve the original editor/photo layout; reclaim only outer gutters. */
  :is(#baseMembers, #baseAccounts) .local-profile-editor {
    width: 100%; padding-inline: 0 !important;
  }
  :is(#baseMembers, #baseAccounts) .local-profile-editor > .editor-main {
    width: 100% !important; max-width: 100% !important; min-width: 0; margin-inline: 0 !important; padding-inline: 4px;
  }
  :is(#baseMembers, #baseAccounts) .audition-history-workspace :is(.audition-search, .local-audition-review, .saved-audition, .review-summary, .milestone-filter-heading) {
    width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box;
  }
  :is(#baseMembers, #baseAccounts) .audition-history-workspace .submitted-audition-list {
    padding-inline: 0;
  }
  :is(#baseMembers, #baseAccounts) .message-workspace :is(.message-row, .message-reading-header, .message-body) {
    min-width: 0; box-sizing: border-box; overflow-wrap: anywhere;
  }
  :is(#baseMembers, #baseAccounts) .message-workspace[data-message-stacked="true"] .message-detail:has(.message-reading-header) {
    min-height: calc(100vh - 24px); min-height: calc(100svh - 24px); scroll-margin-top: 12px;
  }
  /* The list's implicit auto grid column can grow to a card's intrinsic width. */
  :is(#baseMembers, #baseAccounts) .talent-projects .project-list .scrolling-project-list {
    grid-template-columns: minmax(0, 1fr);
    min-width: 0; max-width: 100%; box-sizing: border-box;
  }
  :is(#baseMembers, #baseAccounts) .talent-projects :is(.project-list-row, .project-choice, .project-status-row, .project-card-footer) {
    min-width: 0; max-width: 100%; box-sizing: border-box;
  }
  :is(#baseMembers, #baseAccounts) .talent-projects :is(.project-list-row, .project-choice) { width: 100%; }
  :is(#baseMembers, #baseAccounts) .talent-projects .project-card-footer .project-choice-due {
    flex: 1 1 0%; min-width: 0;
  }
  :is(#baseMembers, #baseAccounts) .talent-projects .project-card-countdown { flex: 0 0 auto; }
}

/* At the existing stacked-profile breakpoint, keep its heading above the photo. */
@media (max-width: 400px) {
  :is(#baseMembers, #baseAccounts) .profile-reading-sheet .compact-profile-header .resume-identity {
    display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px;
  }
  :is(#baseMembers, #baseAccounts) .profile-reading-sheet .resume-identity > .profile-identity-copy {
    display: contents;
  }
  :is(#baseMembers, #baseAccounts) .profile-reading-sheet .resume-identity-heading {
    grid-row: 1; display: flex; flex-wrap: wrap; align-items: start; justify-content: space-between;
    width: 100%; gap: 6px 12px;
  }
  :is(#baseMembers, #baseAccounts) .profile-reading-sheet .profile-header-actions {
    margin-left: auto; justify-content: flex-end;
  }
  :is(#baseMembers, #baseAccounts) .profile-reading-sheet .resume-identity > .profile-artwork-column {
    grid-row: 2;
  }
}

/* Keep the existing photo cards before the editor and its demos when stacked. */
@media (max-width: 760px) {
  :is(#baseMembers, #baseAccounts) .local-profile-editor > .photo-column { order: 0; }
  :is(#baseMembers, #baseAccounts) .local-profile-editor > .editor-main { order: 1; }
}

/* Focused editor spacing: retain original controls and all other workspace rules. */
@media (max-width: 1100px) {
  :is(#baseMembers, #baseAccounts) .local-profile-editor .profile-section-intro .profile-section-feedback:empty {
    display: none;
  }
  :is(#baseMembers, #baseAccounts) .local-profile-editor .profile-section-intro {
    padding-bottom: 8px !important; margin-bottom: 10px !important;
  }
}
@media (max-width: 850px) {
  :is(#baseMembers, #baseAccounts) .local-profile-editor > .editor-main { container: profile-editor / inline-size; }
  :is(#baseMembers, #baseAccounts) .local-profile-editor .editor-heading {
    display: grid; grid-template-columns: minmax(0, 1fr); row-gap: 8px;
  }
  :is(#baseMembers, #baseAccounts) .local-profile-editor .editor-heading > div:first-child,
  :is(#baseMembers, #baseAccounts) .local-profile-editor .profile-heading-actions {
    display: contents;
  }
  :is(#baseMembers, #baseAccounts) .local-profile-editor .editor-heading h2 {
    grid-row: 1; margin-bottom: 0;
  }
  :is(#baseMembers, #baseAccounts) .local-profile-editor .profile-heading-actions nav {
    grid-row: 2; justify-self: end;
  }
  :is(#baseMembers, #baseAccounts) .local-profile-editor .editor-heading .muted {
    grid-row: 3; margin-block: 0;
  }
  :is(#baseMembers, #baseAccounts) .local-profile-editor .profile-heading-actions .local-badge {
    grid-row: 4; justify-self: start;
  }
}
@container profile-editor (min-width: 335px) {
  :is(#baseMembers, #baseAccounts) .local-profile-editor .editor-heading { grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; }
  :is(#baseMembers, #baseAccounts) .local-profile-editor .editor-heading h2 { grid-column: 1; }
  :is(#baseMembers, #baseAccounts) .local-profile-editor .profile-heading-actions nav { grid-column: 2; grid-row: 1; align-self: start; }
  :is(#baseMembers, #baseAccounts) .local-profile-editor .editor-heading .muted { grid-column: 1 / -1; grid-row: 2; }
  :is(#baseMembers, #baseAccounts) .local-profile-editor .profile-heading-actions .local-badge { grid-column: 1 / -1; grid-row: 3; }
}
@media (max-width: 600px) {
  :is(#baseMembers, #baseAccounts) .local-profile-editor .editor-save {
    display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: center; gap: 8px 10px;
  }
  :is(#baseMembers, #baseAccounts) .local-profile-editor .editor-save > small {
    grid-column: 1 / -1; justify-self: start; width: 22ch; max-width: 100% !important; margin: 0; padding: 0;
    text-align: left; white-space: normal; text-wrap: balance;
  }
}

/* Keep Settings' wide hidden-project rows inside their own scrollable list. */
@media (max-width: 1100px) {
  :is(#baseMembers, #baseAccounts) .account-settings {
    grid-template-columns: minmax(0, 1fr); min-width: 0;
  }
  :is(#baseMembers, #baseAccounts) .account-settings .settings-panel {
    min-width: 0; max-width: 100%; box-sizing: border-box;
  }
  :is(#baseMembers, #baseAccounts) .account-settings .hidden-project-list {
    min-width: 0; max-width: 100%; overflow-x: auto;
  }
}
