@layer components {
  /* ================= Album sharing dialog ================= */
  .sharing-dialog {
    min-width: 22rem;
    max-width: 30rem;
  }
  @media (min-width: 48rem) {
    .sharing-dialog {
      min-width: 34rem;
      max-width: 40rem;
    }
  }
  .sharing-dialog-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding-right: 1.5rem; /* clear the dialog's close button */
  }
  .sharing-dialog-header h3 {
    margin: 0;
  }
  .sharing-intro {
    margin: 0 0 1rem 0;
    color: #555;
  }

  .sharing-form {
    margin: 0;
  }
  .sharing-scope {
    border: 0;
    padding: 0;
    margin: 0 0 1rem 0;
  }
  .sharing-scope legend {
    padding: 0;
    margin-bottom: 0.35rem;
    font-weight: 600;
    color: #333;
  }
  .sharing-option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.3rem 0;
    cursor: pointer;
    user-select: none;
  }
  .sharing-option input {
    width: 1.05rem;
    height: 1.05rem;
    flex-shrink: 0;
  }
  .sharing-option input:disabled + span {
    color: #999;
  }

  .sharing-field {
    margin-bottom: 1rem;
  }
  .sharing-field label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
    color: #333;
  }
  .sharing-field input[type="text"],
  .sharing-field input[type="password"] {
    width: 100%;
  }
  .sharing-hint {
    margin: 0.4rem 0 0 0;
    font-size: 0.85em;
    color: #888;
  }

  /* Password-protection fieldset */
  .sharing-password {
    border: 1px solid #e6e8eb;
    border-radius: 8px;
    padding: 0.5rem 0.9rem 0.7rem;
    margin: 0 0 1rem 0;
  }
  .sharing-password legend {
    padding: 0 0.35rem;
    font-weight: 600;
    color: #333;
  }
  .sharing-password-input {
    padding: 0.1rem 0 0.55rem 1.65rem;
  }
  .sharing-password-input input {
    width: 100%;
  }
  .sharing-password-input input:disabled {
    background: #f1f2f4;
    cursor: not-allowed;
  }

  /* Share link box with copy button */
  .sharing-label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
    color: #333;
  }
  .sharing-link {
    margin-bottom: 1rem;
  }
  .sharing-link-row {
    display: flex;
    gap: 0.4rem;
  }
  .sharing-link-row input {
    flex: 1;
    min-width: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85em;
    background: #f6f7f9;
  }
  .sharing-copy-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
  }
  .sharing-copy-btn .sharing-copied-label {
    display: none;
  }
  .sharing-copy-btn.copied {
    color: var(--color-primary, hsl(162, 35%, 35%));
  }
  .sharing-copy-btn.copied .sharing-copy-label {
    display: none;
  }
  .sharing-copy-btn.copied .sharing-copied-label {
    display: inline;
  }
  .sharing-regenerate-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
  }

  /* Revoke button in the management form's button row */
  .btn-danger {
    color: #b3261e;
  }
  .btn-danger:hover {
    background: #fbeae9;
    border-color: #f0c4c1;
  }

  /* Album-shared indicator in the resource header */
  .album-share-slot {
    display: contents;
  }
  .album-share-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-left: 0.5rem;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: hsl(162, 35%, 92%);
    color: hsl(162, 35%, 30%);
    font-size: 0.8em;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
  }
  .album-share-indicator:hover {
    background: hsl(162, 35%, 86%);
  }

  /* ============ Public album sharing page ============ */
  .sharing-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    background: hsl(192, 60%, 32%);
    color: #fff;
    /* Clear the blitz staging banner (0rem when no banner is shown). */
    margin-top: var(--blitz-staging-banner-height, 0rem);
  }
  .sharing-logo {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 700;
    font-size: 1.1rem;
  }
  .sharing-header-title {
    font-size: 1.1rem;
    font-weight: 600;
    padding-left: 1rem;
    border-left: 1px solid rgba(255, 255, 255, 0.35);
  }
  .sharing-header-actions {
    margin-left: auto;
  }

  .sharing-download {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: #fff;
    text-decoration: none;
    font-weight: 500;
  }
  .sharing-download:hover {
    text-decoration: underline;
  }

  .sharing-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.5rem;
    padding: 1rem;
  }
  .sharing-photo {
    position: relative;
    display: block;
    aspect-ratio: 1;
    overflow: hidden;
    background: #eef0f3;
  }
  .sharing-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.25s ease;
  }
  .sharing-photo:hover img {
    transform: scale(1.04);
  }

  /* Caption + capture date / location overlay, mirroring the app grid. */
  .sharing-photo-info {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 1.75rem 0.6rem 0.5rem;
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.82) 30%, transparent);
    pointer-events: none;
  }
  .sharing-photo-caption {
    font-size: 0.85rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }
  .sharing-photo-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.1rem 0.65rem;
    font-size: 0.72rem;
    opacity: 0.92;
  }
  .sharing-photo-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.22rem;
    --icon-size: 0.85rem;
  }

  @media (hover: hover) {
    .sharing-photo-info {
      opacity: 0;
      transform: translateY(0.25rem);
      transition: opacity 0.15s ease, transform 0.15s ease;
    }
    .sharing-photo:hover .sharing-photo-info,
    .sharing-photo:focus-visible .sharing-photo-info {
      opacity: 1;
      transform: translateY(0);
    }
  }

  /* Caption + capture date / location shown just below the image in the
     public sharing lightbox. Position (top/left/width) is set by
     lightbox_controller.js to track the rendered image rectangle. */
  .sharing-lightbox-caption {
    position: absolute;
    z-index: 1500;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.5rem 1rem 0;
    color: #fff;
    text-align: center;
    pointer-events: none;
  }
  /* Compact landscape (phone rotated): the caption overlays the image's
     lower edge instead of sitting below it — see helpers/photoswipe.js. */
  .sharing-lightbox-caption.pswp__caption--overlay {
    padding-top: 1.75rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0));
  }
  .sharing-lightbox-caption-text {
    font-size: 0.95rem;
    line-height: 1.35;
  }
  .sharing-lightbox-caption-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.15rem 1rem;
    font-size: 0.8rem;
    opacity: 0.8;
  }
  .sharing-lightbox-caption-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    --icon-size: 0.95rem;
  }

  .sharing-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    padding: 4rem 1rem;
    color: #888;
  }

  .sharing-access {
    display: flex;
    justify-content: center;
    padding: 3rem 1rem;
  }
  .sharing-access-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    max-width: 24rem;
    text-align: center;
    padding: 2rem;
    border: 1px solid #e6e8eb;
    border-radius: 12px;
    background: #fff;
  }
  .sharing-access-box h2 {
    margin: 0.3rem 0 0 0;
    font-size: 1.2rem;
  }
  .sharing-access-box p {
    margin: 0 0 0.6rem 0;
    color: #666;
  }
  .sharing-access-box form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    width: 100%;
  }
  .sharing-access-box input[type="password"] {
    width: 100%;
    text-align: center;
  }
}
