/* v38: compact but readable status labels, shared by all six languages. */
.photo-status {
  max-width: calc(100% - 6px);
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.2;
  font-size: 12px;
}
.photo-status input { flex: 0 0 14px; width: 14px; height: 14px; }
.photo-status span { min-width: 0; }
.show-photos-button { display: none; }
.portrait-aspect-control, .portrait-save-button, .settings-save-area { display: none; }
.media-selection-actions { grid-template-columns: repeat(2, minmax(0,1fr)); }
.media-selection-actions button { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
.media-selection-actions:has(#media-selection-share-submit:not([hidden])) #media-selection-cancel { grid-column: 1 / -1; order: 3; }
#media-selection-share-submit[hidden] { display: none; }
.filmstrip-mode-actions button,
.filmstrip-select-all { white-space: normal; overflow-wrap: anywhere; min-width: 0; }

@media (max-width: 800px) and (orientation: portrait) {
  :root {
    --portrait-screen-height: 100svh;
    --portrait-preview-height: 55svh;
    --portrait-tabs-height: 52px;
    --portrait-photo-height: calc(var(--portrait-preview-height) - var(--portrait-tabs-height));
    --portrait-action-height: 0px;
  }
  /* Mobile browser chrome can retract during scrolling. Size the editor to
     the CURRENT viewport so the document can scroll past the whole strip. */
  @supports (height: 100dvh) {
    :root {
      --portrait-screen-height: 100dvh;
      --portrait-preview-height: 55dvh;
    }
  }
  /* Only the document scrolls. A scrolling body would trap sticky children. */
  html { height: auto; overflow-x: hidden; overflow-y: auto; }
  body { height: auto; overflow: visible; padding-bottom: 0; }
  .app-container {
    height: auto;
    min-height: var(--portrait-screen-height);
    padding-bottom: var(--portrait-action-height);
    overflow: visible;
  }
  .app-main-content {
    height: auto;
    min-height: 0;
    flex: none;
    overflow: visible;
    gap: 0;
  }
  .filmstrip-footer-section {
    height: auto;
    min-height: 0;
    max-height: none;
    flex: none;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto 70px auto;
    gap: 4px 8px;
  }
  .filmstrip-heading { grid-area: 1 / 1; }
  .filmstrip-mode-actions { grid-area: 1 / 2; }
  .filmstrip-mode-actions button { flex: 1; min-height: 32px; }
  .filmstrip-select-all { grid-area: 2 / 1 / 3 / -1; min-height: 28px; justify-content: flex-start; }
  .filmstrip-container { grid-area: 3 / 1 / 4 / -1; align-items: flex-start; }
  .thumbnail-item { flex: 0 0 104px; width: 104px; height: 68px; }
  .batch-delete-button { position: static; grid-area: 4 / 1 / 5 / -1; width: 100%; }
  .main-preview-section {
    position: sticky;
    top: 0;
    margin: 0;
    padding: 0;
    flex: 0 0 var(--portrait-preview-height);
    height: var(--portrait-preview-height);
  }
  .control-panel-section {
    position: relative; top: auto; margin: 0;
    flex: 0 0 calc(var(--portrait-screen-height) - var(--portrait-preview-height));
    height: calc(var(--portrait-screen-height) - var(--portrait-preview-height));
    min-height: 0;
    max-height: calc(var(--portrait-screen-height) - var(--portrait-preview-height));
    overflow-y: auto;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .aspect-tab-group {
    width: 100%; gap: 5px; padding: 4px 5px;
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: stretch;
  }
  .aspect-tab-group > .tab-button { display: none; }
  .portrait-aspect-control {
    position: relative; display: flex; align-items: center; justify-content: center;
    min-width: 0; min-height: 44px; padding: 2px 4px; border: 1px solid #536474;
    border-radius: 5px; background: #20384b; text-align: center;
    font-size: 12px; line-height: 1.1; white-space: nowrap;
  }
  .portrait-aspect-control select {
    position: absolute; inset: 0; width: 100%; min-width: 0; height: 100%;
    margin: 0; opacity: 0; cursor: pointer; font-size: 16px;
  }
  .portrait-aspect-control:focus-within { outline: 2px solid #8acaff; outline-offset: 2px; }
  .portrait-aspect-control > span::after { content: ' ▾'; }
  .aspect-tab-group button { overflow-wrap: anywhere; }
  .show-photos-button {
    display: block;
    flex: 0 1 auto;
    min-height: 32px;
    max-width: none;
    padding: 3px 5px;
    border: 1px solid #536474;
    border-radius: 5px;
    background: #20384b;
    color: #fff;
    font-size: 12px;
    line-height: 1.1;
  }
  .aspect-tab-group .tab-button { flex-shrink: 0; padding: 5px; }
  .active-photo-mode-button {
    margin: 0;
    min-width: 0;
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.1;
    padding: 3px 6px;
    font-size: 12px;
  }
  .active-photo-mode-button[data-mode='solo'] { background: #712732; border-color: #ff747d; }
  .portrait-save-button {
    display: block; min-width: 0; min-height: 44px; padding: 5px;
    border: 1px solid #258edc; border-radius: 5px; background: #0872c2; color: #fff;
    font-size: 14px; font-weight: 700; white-space: normal;
  }
  .portrait-save-button:disabled { opacity: .5; }
  .settings-save-area { display: block; margin-top: 16px; padding-top: 12px; border-top: 1px solid #43515d; }
  .settings-save-area button { width: 100%; min-height: 44px; }
  .settings-save-area p { margin-top: 6px; font-size: 12px; color: #b9c6d2; text-align: center; }
  .app-title small { display: none; }
  .app-header { padding-inline: 6px; gap: 4px; }
  .header-actions { min-width: 0; margin-left: auto; }
  .language-select { max-width: 84px; }
  .header-button { white-space: normal; padding-inline: 5px; }
  .linked-edit-control, .individual-edit-actions { flex-wrap: wrap; }
}
